Manually Induced Cancellation - CSharp Thread Asynchronous

CSharp examples for Thread Asynchronous:Task

Description

Manually Induced Cancellation

Demo Code

using System;/*from   ww w. j  a  va 2  s  .  com*/
using System.Threading.Tasks;
class ManuallyInducedCancellation
{
   static void Main()
   {
      Task task = ThrowCancellationException();
      Console.WriteLine(task.Status);
   }
   static async Task ThrowCancellationException()
   {
      throw new OperationCanceledException();
   }
}

Related Tutorials