private void cancelJob()
{
LogFromForm("Cancelling job...");
CancelJob = true;
//Wait a while
int cnt = 10;
while (--cnt >= 0)
{
if (!_thread.IsAlive) break;
Thread.Sleep(1000);
mainTimer_Tick(null, null);
}
if (_thread.IsAlive)
{
LogFromForm("Unable to cancel Job. Terminating job...");
_thread.Abort();
Thread.Sleep(1000);
}
LogFromForm(!_thread.IsAlive ? "Job is terminated" : "Job is still alive !");
}