Ejemplo n.º 1
0
 /// <summary>Attempt to cancel the task when it times out.
 /// If the task is running, an attempt is made to interrupt the thread executing it.
 /// In any case the task's timeout flag is set to true.
 /// </summary>
 public void Timeout()
 {
     if (cancelled)
     {
         return;
     }
     try {
         timeout = true;
         if (task != null)
         {
             task.TimedOut = true;
             if (currentThread != null)
             {
                 currentThread.Interrupt();
             }
             task.OnTimeout();
         }
     } catch (Exception e) {
         Console.WriteLine("" + e);
         Console.WriteLine(e.StackTrace);
     }
 }