public AttemptToTerminate ( Thread workerThread, System.TimeSpan timeout ) : bool | ||
workerThread | Thread | The worker thread. |
timeout | System.TimeSpan | The timeout. |
return | bool |
public bool AttemptToTerminate(Thread workerThread, TimeSpan? timeout)
{
if (workerThread == null || !workerThread.IsAlive)
return true; //if the thread is null or not alive, its terminated
if (timeout.HasValue)
{
return workerThread.Join(timeout.Value);
}
workerThread.Join();
return true;
}
}
/// <summary> /// Attempts to terminate the worker thread. /// </summary> /// <returns></returns> public virtual bool AttemptToTerminate() { return(_workerTerminate.AttemptToTerminate(WorkerThread, TimeSpan.Zero)); }