Very very strange. Major bug?

Discussion in 'ASP .Net' started by Shawn, Feb 3, 2004.

  1. Shawn

    Shawn Guest

    Hi. Can anyone please explain to me why this method "restarts" after the
    StreamWriter is created?? Put a brakepoint on the sub and you will see what
    I mean. I've tried running it on a different machine and the same thing
    happends. I'm running .NET Framework 1.0

    Private Sub test()
    Dim swWebBidLog As System.IO.StreamWriter
    Dim strLogFile As String

    strLogFile = Server.MapPath("log.log")

    swWebBidLog = New System.IO.StreamWriter(strLogFile, True,
    System.Text.Encoding.Default)
    End Sub

    Thanks,
    Shawn
     
    Shawn, Feb 3, 2004
    #1
    1. Advertising

  2. I don't get it, for one you aren't "closing" the StreamWriter in the code
    you posted. Just for grins I added a swWebBidLog.Close() at the end of it
    all, and it uh closed, then exited. I don't really see what your problem
    is. Please post more, especially the sub you are calling "test()" out of,
    your probably most likely lies there.

    "Shawn" <> wrote in message
    news:...
    > Hi. Can anyone please explain to me why this method "restarts" after the
    > StreamWriter is created?? Put a brakepoint on the sub and you will see

    what
    > I mean. I've tried running it on a different machine and the same thing
    > happends. I'm running .NET Framework 1.0
    >
    > Private Sub test()
    > Dim swWebBidLog As System.IO.StreamWriter
    > Dim strLogFile As String
    >
    > strLogFile = Server.MapPath("log.log")
    >
    > swWebBidLog = New System.IO.StreamWriter(strLogFile, True,
    > System.Text.Encoding.Default)
    > End Sub
    >
    > Thanks,
    > Shawn
    >
    >
     
    Michael Ramey, Feb 3, 2004
    #2
    1. Advertising

  3. Shawn

    Scott Allen Guest

    Creating the StreamWriter might block the current thread for a small
    amount of time waiting for IO. This would allow a second thread to get
    into the Sub.

    You could check if this is what you are seeing by opening the Threads
    windows in the Debugger (Debug -> Windows -> Threads). Watch the
    little yellow arrow to see if the ID changes on the "restart".

    HTH,

    --
    Scott
    http://www.OdeToCode.com



    On 3 Feb 2004 14:44:42 +0100, "Shawn" <> wrote:

    >Hi. Can anyone please explain to me why this method "restarts" after the
    >StreamWriter is created?? Put a brakepoint on the sub and you will see what
    >I mean. I've tried running it on a different machine and the same thing
    >happends. I'm running .NET Framework 1.0
    >
    >Private Sub test()
    > Dim swWebBidLog As System.IO.StreamWriter
    > Dim strLogFile As String
    >
    > strLogFile = Server.MapPath("log.log")
    >
    > swWebBidLog = New System.IO.StreamWriter(strLogFile, True,
    >System.Text.Encoding.Default)
    >End Sub
    >
    >Thanks,
    >Shawn
    >
     
    Scott Allen, Feb 3, 2004
    #3
  4. Shawn

    Shawn Guest

    No I didn't close the StreamWriter in the code, I left it out along with the
    rest of the sub because it's not important. What is important is that when
    I set a brakepoint on this line: swWebBidLog = New
    System.IO.StreamWriter(..) and do a "step over" the whole page restarts and
    page_load is called again.
    test() is called from page_load.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    test()
    End Sub

    This is the case on two machines at work, but when I tried it at home it
    worked.

    Shawn


    "Michael Ramey" <raterus@localhost> wrote in message
    news:...
    I don't get it, for one you aren't "closing" the StreamWriter in the code
    you posted. Just for grins I added a swWebBidLog.Close() at the end of it
    all, and it uh closed, then exited. I don't really see what your problem
    is. Please post more, especially the sub you are calling "test()" out of,
    your probably most likely lies there.

    "Shawn" <> wrote in message
    news:...
    > Hi. Can anyone please explain to me why this method "restarts" after the
    > StreamWriter is created?? Put a brakepoint on the sub and you will see

    what
    > I mean. I've tried running it on a different machine and the same thing
    > happends. I'm running .NET Framework 1.0
    >
    > Private Sub test()
    > Dim swWebBidLog As System.IO.StreamWriter
    > Dim strLogFile As String
    >
    > strLogFile = Server.MapPath("log.log")
    >
    > swWebBidLog = New System.IO.StreamWriter(strLogFile, True,
    > System.Text.Encoding.Default)
    > End Sub
    >
    > Thanks,
    > Shawn
    >
    >
     
    Shawn, Feb 4, 2004
    #4
  5. Shawn

    Shawn Guest

    Hi Scott.
    The ID didn't change.. I found out that it wasn't the sub that restartet,
    it was the entire page. After trying to create the StreamWriter the thread
    jumped back to Page_Load again (thus starting test() for the second time).

    Shawn


    "Scott Allen" <bitmask@[nospam].fred.net> wrote in message
    news:...
    Creating the StreamWriter might block the current thread for a small
    amount of time waiting for IO. This would allow a second thread to get
    into the Sub.

    You could check if this is what you are seeing by opening the Threads
    windows in the Debugger (Debug -> Windows -> Threads). Watch the
    little yellow arrow to see if the ID changes on the "restart".

    HTH,

    --
    Scott
    http://www.OdeToCode.com



    On 3 Feb 2004 14:44:42 +0100, "Shawn" <> wrote:

    >Hi. Can anyone please explain to me why this method "restarts" after the
    >StreamWriter is created?? Put a brakepoint on the sub and you will see what
    >I mean. I've tried running it on a different machine and the same thing
    >happends. I'm running .NET Framework 1.0
    >
    >Private Sub test()
    > Dim swWebBidLog As System.IO.StreamWriter
    > Dim strLogFile As String
    >
    > strLogFile = Server.MapPath("log.log")
    >
    > swWebBidLog = New System.IO.StreamWriter(strLogFile, True,
    >System.Text.Encoding.Default)
    >End Sub
    >
    >Thanks,
    >Shawn
    >
     
    Shawn, Feb 4, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. kokwooi

    Major Major Problem With ASP.NET

    kokwooi, Sep 18, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    693
    NuTcAsE
    Sep 19, 2003
  2. Barry

    VS.NET major bug or bad luck?

    Barry, Aug 14, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    333
    S. Justin Gengo
    Aug 15, 2003
  3. Daves
    Replies:
    0
    Views:
    413
    Daves
    Mar 27, 2006
  4. Jef Driesen
    Replies:
    2
    Views:
    1,774
    Jef Driesen
    Jan 12, 2006
  5. ara howard
    Replies:
    0
    Views:
    256
    ara howard
    Oct 28, 2003
Loading...

Share This Page