473,503 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Thread start and Finished Notification

Hi,

Was wondering if its possible to have a event notification in Thread when
the thread is about to start and the thread has just finished doing its work
and about to terminate.
If its not directly available, I was thinking to derive a class form Thread
and provide this events, but again its a sealed class. Is there a way to do
this?
I do not want to waste time pooling or waiting for the other thread to
finish I can rather so someting useful.

Any help is most welcome.

Regards
Kiran

Nov 16 '05 #1
3 3916
Hi Kiran,

Just declare the events in your main code, then when the thread starts it
can trigger the event asynchronously using BeginInovke method of your event.
Same when the thread finishes the job.

hope this helps

Fitim Skenderi

"Kiran" <ki****@abc.com> wrote in message
news:uj**************@TK2MSFTNGP10.phx.gbl...
Hi,

Was wondering if its possible to have a event notification in Thread when the thread is about to start and the thread has just finished doing its work and about to terminate.
If its not directly available, I was thinking to derive a class form Thread and provide this events, but again its a sealed class. Is there a way to do this?
I do not want to waste time pooling or waiting for the other thread to
finish I can rather so someting useful.

Any help is most welcome.

Regards
Kiran

Nov 16 '05 #2
Hi,

Will this kind of helped, Now I created my own class that wraps this
Thread class & the Execute method.

Thanks Again
Kiran

"Fitim Skenderi" <fi****@hotmail.com> wrote in message
news:ex**************@TK2MSFTNGP12.phx.gbl...
Hi Kiran,

Just declare the events in your main code, then when the thread starts it
can trigger the event asynchronously using BeginInovke method of your event. Same when the thread finishes the job.

hope this helps

Fitim Skenderi

Nov 16 '05 #3
Hi Kiran

----- Kiran wrote: ----
Was wondering if its possible to have a event notification in Thread whe
the thread is about to start and the thread has just finished doing its wor
and about to terminate

Yes, but not automatically. I see two ways to achieve this.
(1) Pass two callbacks to your thread, one for signaling the thread has started, the other to signal that the thread has finished. In your thread, call the callbacks at the appropriate moment (start & end). Beware of synchronization issues. The callbacks are wrapped using delegates
(2) Provide two events for your thread, one that signals thread startup, the other signals thread completion. Signal these events at the appropriate moment from your thread. Have another thread monitor these events. The possible event classes that I am talking about are ManualResetEvent and AutoResetEvent (and Mutex, but not useful in this context). These classes derive from WaitHandle, and provide wait functionality

If its not directly available, I was thinking to derive a class form Threa
and provide this events, but again its a sealed class. Is there a way to d
this

The Thread class is sealed, so aggregation/composition is your instrument. I think it is common to write a base thread class for your projects which does all plumbing

I do not want to waste time pooling or waiting for the other thread t
finish I can rather so someting useful

Then I suggest you use callbacks. These could post a message, which you could process when you have the time. This is easily done using a queue.

Regard
Kira

HTH
Tom Tempelaere.
Nov 16 '05 #4

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

Similar topics

3
12285
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...
3
23518
by: Will | last post by:
I have a Manager thread that launches a variable number of Worker threads. When each Worker thread finishes, I want it to notify the Manager thread that it's done so that the Manager thread can...
3
402
by: Kiran | last post by:
Hi, Was wondering if its possible to have a event notification in Thread when the thread is about to start and the thread has just finished doing its work and about to terminate. If its not...
7
2684
by: Ivan | last post by:
Hi I have following problem: I'm creating two threads who are performing some tasks. When one thread finished I would like to restart her again (e.g. new job). Following example demonstrates...
16
3286
by: droopytoon | last post by:
Hi, I start a new thread (previous one was "thread timing") because I have isolated my problem. It has nothing to do with calling unmanaged C++ code (I removed it in a test application). I...
6
2270
by: Daniel | last post by:
i have an array that i want all threads to be able to READ from concurrently, however, at times i want to UPDATE the array. at which point i want all threads that use it to block when they try to...
6
2337
by: Anders Eriksson | last post by:
Hello! I have a form from which I start an thread running in the background and I want to have an event when the thread is done/ends. I start the thread like this: private Thread prT; // this...
1
3279
by: Chrace | last post by:
Hi all, I have a problem with with Thread.Join( Timeout ) where the timeout never occurs. I basically need to make a connection to an AS400 box which works fine. Once in a blue moon the AS400...
2
3335
by: Steve | last post by:
Hi All, I've been trying to come up with a good way to run a certain process at a timed interval (say every 5 mins) using the SLEEP command and a semaphore flag. The basic thread loop was always...
0
7202
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,...
0
7086
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...
1
6991
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...
0
7462
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...
1
5014
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...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
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...
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.