SanSYS

Untitled

Jul 27th, 2015
24,842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. public class TestController : ApiController
  2. {
  3.     public Task<bool> Get(int count, CancellationToken cancellationToken)
  4.     {
  5.         return Task.Factory.StartNew(() =>
  6.         {
  7.             int i = 0;
  8.  
  9.             for (; count --> i ;)
  10.             {
  11.                 cancellationToken.ThrowIfCancellationRequested();
  12.  
  13.                 Thread.Sleep(10);
  14.             }
  15.  
  16.             return true;
  17.         }, cancellationToken);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment