Termination of Worker/Child thread terminates the Parent Thread

Discussion in 'ASP .Net' started by Sanjay, Feb 20, 2007.

  1. Sanjay

    Sanjay Guest

    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
     
    Sanjay, Feb 20, 2007
    #1
    1. Advertising

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



    "Sanjay" <> wrote in message
    news:...
    > 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
    >
     
    George Ter-Saakov, Feb 21, 2007
    #2
    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. alex
    Replies:
    1
    Views:
    690
    Lau Lei Cheong
    Feb 4, 2005
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,200
    David Schwartz
    Dec 9, 2003
  3. Hal Fulton

    "warning: fork terminates thread"

    Hal Fulton, Jun 21, 2004, in forum: Ruby
    Replies:
    2
    Views:
    117
    Ara.T.Howard
    Jun 21, 2004
  4. Noel Dolan
    Replies:
    0
    Views:
    274
    Noel Dolan
    Jul 18, 2004
  5. Bitswapper
    Replies:
    5
    Views:
    182
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page