Very very strange. Major bug?

  • Thread starter Thread starter Shawn
  • Start date Start date
S

Shawn

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
 
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.
 
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,
 
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


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.
 
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


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,
 
Back
Top