Worker Thread Stopping Softly

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a worker thread. I run it in application start and I want to stop it
in application end. It does some operations every minute.
How can I stop it softly?
Softly: if it is doing operations when I command stop, it must finish its
operations and than must terminate itself.

Thanks in advance.
______________________________
Åženol Akbulak
 
I writed a class which uses WorkerThread class. Is it right?

########################################
public class WorkerThreadSystem
{
// define worker threads
static Thread workerThread= null;
//
static WorkerThread job;


static public void StartWorkerThread()
{
if( workerThread== null )
{
job = new WorkerThread();

// start the thread
workerThread= new Thread( new ThreadStart(job.Start) );
workerThread.Name = "job";
workerThread.Start();
}
}

static public void StopWorkerThread()
{
if( workerThread!= null )
{
if( job != null )
job.Stop();
}
}
}
###########################################
 
Back
Top