Example #1
0
 static void Work(Canceler c)
 {
     while (true)
     {
         c.ThrowIfCancellationRequested();
         // ...
         try
         {
             OtherMethod(c);
         }
         finally { /* any required cleanup */ }
     }
 }
Example #2
0
 static void OtherMethod(Canceler c)
 {
     // Do some thing...
     c.ThrowIfCancellationRequested();
 }