Thanks for the reply.
OK it does not start a new thread.
Now can you explain the behavior in the following code?
I am trying to understand how exceptions behave in a
message loop scenario. I have a try-catch block around a
message loop and one of the event handlers in the message
loop throws an exception. That exception is not caught in
my try-catch block around the message loop. But when
JITDebugging is enabled, the exception is caught in the
same try-catch block. I know that in a multi-threaded
scenario it does the same. Could you help me understand
this behavior? If it is the same thread, then exceptions
thrown by the event handlers, which are called from inside
the loop, if not handled should be caught by the catch
block around the message loop. But they are not. Why?
To test the regular version I used the following command
vbc /r:System.dll,System.Windows.Forms.dll,System.Drawing.d
ll Test.vb
To test the JITDebugging version I used the following
command with test.exe.config file
vbc /r:System.dll,System.Windows.Forms.dll,System.Drawing.d
ll /debug+ Test.vb
Following are contents of the files I used to test this:
'**********
'Test.vb
'**********
Imports System
Imports System.WIndows.FOrms
imports microsoft.visualbasic
Public Class Form2
Inherits System.Windows.Forms.Form
Friend WithEvents Button1 As
System.Windows.Forms.Button
Sub New()
Me.Button1 = New System.Windows.Forms.Button
Me.Button1.Location = New System.Drawing.Point
(176, 80)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
Me.ClientSize = New System.Drawing.Size(448, 253)
Me.Controls.Add(Me.Button1)
Me.Name = "Form2"
Me.Text = "Form2"
End Sub
Shared Sub main()
Try
Dim frm As New Form2
frm.ShowDialog()
Catch ex As Exception
msgbox("Exception caught in sub main" &
vbcrlf & ex.tostring)
End Try
End Sub
Sub Method1()
Throw New Exception("Test Exception")
End Sub
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Method1()
End Sub
End Class
'**********
'End Test.vb
'**********
'**********
'test.exe.config
'**********
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
'**********
'end test.exe.config
'**********
TIA
Sankar
..