Termination of Worker/Child thread terminates the Parent Thread

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
 
G

George Ter-Saakov

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top