473,654 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Termination of Worker/Child thread terminates the Parent Thread

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 ConnectionStrin gSettings = Nothing
Dim myConfigReader As Config = New TMISSuite.Confi g

' Start TMISManager
Console.WriteLi ne(System.DateT ime.Now() + " Starting Manager
Thread")

Dim myManager As TMISManager = New
TMISManager(con nStr.ToString() )
Dim myThread As New Thread(AddressO f
TMISManager.Sta rtTMISManager)
myThread.Start( )
Thread.Sleep(0)
Console.WriteLi ne("About to exit main app")


End Sub

End Module
Thanks in advance

regards
Sanjay

Feb 21 '07 #1
1 1741
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" <sa*********@gm ail.comwrote in message
news:11******** **************@ h3g2000cwc.goog legroups.com...
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 ConnectionStrin gSettings = Nothing
Dim myConfigReader As Config = New TMISSuite.Confi g

' Start TMISManager
Console.WriteLi ne(System.DateT ime.Now() + " Starting Manager
Thread")

Dim myManager As TMISManager = New
TMISManager(con nStr.ToString() )
Dim myThread As New Thread(AddressO f
TMISManager.Sta rtTMISManager)
myThread.Start( )
Thread.Sleep(0)
Console.WriteLi ne("About to exit main app")


End Sub

End Module
Thanks in advance

regards
Sanjay

Feb 21 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2084
by: Jim McGrail | last post by:
Background: I am investigating a problem involving a windows .NET application that is being developed in C# with Visual Studio 2003. It is a multi-threaded application that uses MSMQ to communicate between the threads. The problem is that the program infrequently terminates with no indication of why it terminated.
2
309
by: ice88 | last post by:
I would like to execute some code when a thread terminates, in the context of that thread - I guess similar to an ExitThread handler - is it possible in a C# .NET application? I can see a way to execute code when a thread is thrown away - by having per-thread static attributes that are themselves objects, when the thread object associated with that static value is garbage collected, the destructor for the object is driven - but that...
2
2637
by: Ian Sykes | last post by:
I have a C# program which terminates prematurely, with no error or exception being raised, the termination point varying with what diagnostic code is present. The termination point appears to be consistent between runs when the source code is not changed & recompiled between runs. The code is multi-threaded but I am debugging outside Visual Studio ..Net, i.e. without using any debugger. Can anyone offer any insight into this type of...
2
2980
by: Rahul Anand | last post by:
I have a problem in my multithreaded application. The problem is reproducible very rarely, only once in 6000 similar execution (through same code path). Problem: One of multiple threads gets abnormally terminated. It does not goes through the try-catch-finally sequence. The mehtod gets hanged and the object used inside the method gets collected by GC. Bacground about the application: I am using COM-Interop. The threads are created in...
3
1374
by: zhaoyandong | last post by:
I have two threads, one UI thread, the other, the worker thread, which is responsible for keeping on search things and post the found results to a list control on the UI. My leader doesn't allow me to use MFC. So I have to use SendMessage(LVM_XXX, hListCtrl) in the worker thread, I guess. But I failed, there is nothing displaying in the list control in the UI
5
3536
by: Soren S. Jorgensen | last post by:
Hi, In my app I've got a worker thread (background) doing some calculations based upon user input. A new worker thread might be invoked before the previous worker thread has ended, and I wan't only one worker thread running at any time (if a new worker thread start has been requested, any running worker thread results will be invalid). I'm using the below method to invoke a new worker thread, but when stress testing this I'm sometimes...
669
25857
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
2
2067
by: rocco.rossi | last post by:
I'm using the Python processing module. I've just run into a problem though. Actually, it's a more general problem that isn't specific to this module, but to the handling of Unix (Linux processes) in general. Suppose for instance that for some reason or another, after forking several child processes, the main process terminates or gets killed (or segfaults or whatever) and the child processes are orphaned. Is there any way to automatically...
16
2706
by: akshaycjoshi | last post by:
Consider the following code in which i add nodes to a treeview control by reading an MS Access database. Obviously, if I execute in a seperate thread I will get exception about control accessed from a thread other than the one in which it is created. Now whenever I am adding one node to the tree I could marshel it to the GUI thread like this void addnode(string textofnode) { } The problem is that I have got some nodes which are...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.