Termination of Worker/Child thread terminates the Parent Thread

  • Thread starter Thread starter Sanjay
  • Start date Start date
S

Sanjay

Hi All

Have an app. On start up it creates a thread and goes to sleep.
Either on termination or completion of the worker thread, it triggers
the main app to start executing.

Question

Why is the completion of the worker/child thread triggering the
execution of the main app thread. Shouldn't the main app thread remain
in the suspended state?


Module Module1

Sub Main()


Dim connStr As ConnectionStringSettings = Nothing
Dim myConfigReader As Config = New TMISSuite.Config

' Start TMISManager
Console.WriteLine(System.DateTime.Now() + " Starting Manager
Thread")

Dim myManager As TMISManager = New
TMISManager(connStr.ToString())
Dim myThread As New Thread(AddressOf
TMISManager.StartTMISManager)
myThread.Start()


Thread.Sleep(0)


Console.WriteLine("About to exit main app")




End Sub

End Module


Thanks in advance

regards
Sanjay
 
That is new behavior in .NET 2.0
If you had an unhandled exception in worker thread .NET unloads the whole
domain

Always wrap your wroking funtcion into try..catch

George.
 
Back
Top