Hi,
assume threadproc is your thread proc:
void threadproc()
{
// add thread execution logic here
/* NOTIFICATION PART: This is important. Assuming that you r writing this
code inside a windows form class.
Than "this" would refer to windows form itself. I'm going to make an
"asynchronous" call to a method of the form class so that it knows that the
thread is finished execution and the rest of the logic based on the thread's
results can be started. Note also that the call to callwhendone() function
below will
execute in the "thread of the form", not this thread which initiates the
asynchronous call.
*/
this.BeginInvoke(new dlgcallwhendone (this.callwhendone) );
}
here I'v declared the delegate "dlgcallwhendone" with callwhendone()
signatures which is our custom method here.
delegate void dlgcallwhendone();
void callwhendone()
{
MessageBox.Show ( "Thread is done executing.");
}
I hope this helps.
Ab.
http://joehacker.blogspot.com
"Anders Eriksson" <an*****@gmail.com> wrote in message
news:wg***************@morateknikutveckling.se...
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 is a member of the Form1 class
// in a Form1 member function I do:
PrintThread prThread = new PrintThread(prJob.Document);
prT = new Thread (new ThreadStart (prThread.Execute));
prT.IsBackground = true;
prT.Start();
How do I create an event when the thread ends?
// Anders
--
English isn't my first, or second, language.
So anything rude or strange are due to the translation