473,573 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get Thread exit notification

cnu
Hi,
I am starting a new threading to do some process. I want to get notified
when the thread does it's job and exits. After receiving the notification, I
want to refresh the form.

I am starting the thread like this:
<code>
System.Threadin g.ThreadStart tDelegate = new
System.Threadin g.ThreadStart(t his.InitBasicSe rvicesInfo);
this.m_threadPr ogress = new System.Threadin g.Thread(tDeleg ate);
this.m_threadPr ogress.IsBackgr ound = true;
this.m_threadPr ogress.Name = "<InitBasicServ icesInfo>";
this.m_threadPr ogress.Start();

</code>

Is there any event/notification message for this requirement.

Thanks

Jul 21 '05 #1
3 12290
cnu <cn*@discussion s.microsoft.com > wrote:
I am starting a new threading to do some process. I want to get notified
when the thread does it's job and exits. After receiving the notification, I
want to refresh the form.

I am starting the thread like this:
<code>
System.Threadin g.ThreadStart tDelegate = new
System.Threadin g.ThreadStart(t his.InitBasicSe rvicesInfo);
this.m_threadPr ogress = new System.Threadin g.Thread(tDeleg ate);
this.m_threadPr ogress.IsBackgr ound = true;
this.m_threadPr ogress.Name = "<InitBasicServ icesInfo>";
this.m_threadPr ogress.Start();

</code>

Is there any event/notification message for this requirement.


The easiest thing would be to make the new thread call back to the form
to say it had finished "on its way out". If you want to do this in a
few places, you could create your own wrapper which takes a
ThreadStart, and when it's asked to run, it runs the delegate and then
calls back.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Jon,
Is there an example of what you are describing or more detailed description
of handling threads somewhere?

Doug
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
cnu <cn*@discussion s.microsoft.com > wrote:
I am starting a new threading to do some process. I want to get notified when the thread does it's job and exits. After receiving the notification, I want to refresh the form.

I am starting the thread like this:
<code>
System.Threadin g.ThreadStart tDelegate = new
System.Threadin g.ThreadStart(t his.InitBasicSe rvicesInfo);
this.m_threadPr ogress = new System.Threadin g.Thread(tDeleg ate);
this.m_threadPr ogress.IsBackgr ound = true;
this.m_threadPr ogress.Name = "<InitBasicServ icesInfo>";
this.m_threadPr ogress.Start();

</code>

Is there any event/notification message for this requirement.


The easiest thing would be to make the new thread call back to the form
to say it had finished "on its way out". If you want to do this in a
few places, you could create your own wrapper which takes a
ThreadStart, and when it's asked to run, it runs the delegate and then
calls back.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #3
Doug Bell <ma**@vodaphone .com.au> wrote:
Is there an example of what you are describing or more detailed description
of handling threads somewhere?


See http://www.pobox.com/~skeet/csharp/threads

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4

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

Similar topics

8
9587
by: Maloney | last post by:
Exit thread in C#CF. I'm createing a thread and setting a class object for when to exit. Before creating the thread i check if the thread is running, if so set the flag to exit the thread. What is the proper way of waiting for the thread to exit. In C++ i would set an event and WaitForMultipleObject, peek and pump messages until the...
11
1633
by: PJ | last post by:
I'd like to create a subsystem in my asp.net application that is responsible for emails that need to be send out based upon certain events so that the main request/response threads aren't responsible for the communication with the smtp server, etc. I don't want to create a seperate thread for every instance in which a notification must be...
20
2374
by: Bob Day | last post by:
Using VS 2003, VB, MSDE... There are two threads, A & B, that continously run and are started by Sub Main. They instantiationsl of identical code. Thread A handles call activity on telephone line 1 and Thread B handles call activity on telephone line 2. They use a common SQL datasource, but all DataSets are unique to each thread. Is...
3
478
by: cnu | last post by:
Hi, I am starting a new threading to do some process. I want to get notified when the thread does it's job and exits. After receiving the notification, I want to refresh the form. I am starting the thread like this: <code> System.Threading.ThreadStart tDelegate = new System.Threading.ThreadStart(this.InitBasicServicesInfo);...
2
4130
by: Tim | last post by:
The are 2 threads - main thread and worker thread. The main thread creates the worker thread and then the worker thread runs in an infinite while loop till it is asked to exit by setting an event. The worker thread instantiates an object and calls methods of that object. If some method call fails, the main thread needs to be notified about the...
5
4751
by: zxo102 | last post by:
Hi, I am doing a small project using socket server and thread in python. This is first time for me to use socket and thread things. Here is my case. I have 20 socket clients. Each client send a set of sensor data per second to a socket server. The socket server will do two things: 1. write data into a file via bsddb; 2. forward the data to...
3
3275
by: Bill Davidson | last post by:
All: I have a problem in which a worker thread in my (.dll) assembly isn't allowing the main (.exe) assembly from terminating. Here's the scenario: 1) App.Exe is launched. 2) App.Exe calls into my .dll (Sub.Dll)
2
2177
by: giddy | last post by:
hi , I'm in a slight dilemma. I have an updater program that checks for pending updates and downloads them if the users chooses to. Since i dont need a windows form to check if there is an update , I dont use a form unless i have two. This , creates either one of two problems. When i'm downloading asynchonously , the main thread exits!
18
2525
by: J.K. Baltzersen | last post by:
To whomever it may concern: I am using MS Visual C++ 6.0. I have a process A which instantiates an object C. At a later point the process A creates the thread B. The thread B has access to the object C.
0
7771
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7686
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8009
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. ...
1
7771
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...
0
8060
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...
0
6406
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5580
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...
0
3731
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1036
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...

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.