예제 #1
0
 static void Main(string[] args)
 {
     while (true)
     {
         FooDBContext.PlaceOrder();
         Thread.Sleep(100);
     }
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (t == null)
     {
         Source = new CancellationTokenSource();
         t      = Task.Run(() =>
         {
             while (!Source.IsCancellationRequested)
             {
                 FooDBContext.PlaceOrder();
                 Task.Delay(100).Wait();
             }
         });
     }
     else
     {
         Source.Cancel();
         t = null;
     }
 }