예제 #1
0
 private Task MakeBaconAsync()
 {
     return(Task.Run(() =>
     {
         Message?.Invoke("bacon down");
         Thread.Sleep(RandomNumbers.GetInteger(1000));
         Message?.Invoke("bacon up!");
     }));
 }
예제 #2
0
 private Task <CoffeeModel> MakeCoffeeAsync()
 {
     return(Task <CoffeeModel> .Run(() =>
     {
         Message?.Invoke("coffee down");
         Thread.Sleep(RandomNumbers.GetInteger(1000));
         Message?.Invoke("coffee up!");
         return new CoffeeModel();
     }));
 }
예제 #3
0
 private Task <ToastModel> MakeToastAsync()
 {
     return(Task.Run(() =>
     {
         Message?.Invoke("toast down");
         Thread.Sleep(RandomNumbers.GetInteger(1000));
         Message?.Invoke("toast up!");
         return new ToastModel();
     }));
 }
예제 #4
0
 private Task <ToastModel> AdornToast(ToastModel toast)
 {
     return(Task <ToastModel> .Run(() =>
     {
         Message?.Invoke("adorning toast");
         Thread.Sleep(RandomNumbers.GetInteger(100));
         toast.WithButter = RandomNumbers.GetDouble() > 0.5;
         Thread.Sleep(RandomNumbers.GetInteger(100));
         toast.WithJelly = RandomNumbers.GetDouble() > 0.5;
         Thread.Sleep(RandomNumbers.GetInteger(100));
         Message?.Invoke(toast.ToString());
         return toast;
     }));
 }
예제 #5
0
 private Task <CoffeeModel> AdornCoffee(CoffeeModel coffee)
 {
     return(Task <CoffeeModel> .Run(() =>
     {
         Message?.Invoke("adorning coffee");
         Thread.Sleep(RandomNumbers.GetInteger(100));
         coffee.WithMilk = RandomNumbers.GetDouble() > 0.5;
         Thread.Sleep(RandomNumbers.GetInteger(100));
         coffee.WithSugar = RandomNumbers.GetDouble() > 0.5;
         Thread.Sleep(RandomNumbers.GetInteger(100));
         Message?.Invoke(coffee.ToString());
         return coffee;
     }));
 }