コード例 #1
0
 public static async Task Add3(IAsyncBox <int> box)
 {
     await TaskCollector.With(async tc =>
     {
         int value = await tc.Adding(box.Get());
         await box.Set((value + 3).ToFuture());
     });
 }
コード例 #2
0
 public static async Task RunAsync()
 {
     await TaskCollector.With(tc =>
     {
         IAsyncBox <int> box = AsyncBox.Create(2);
         Console.WriteLine(tc.Adding(box.Get()).Value);
         tc.Add(box.Set(3.ToFuture()));
         Console.WriteLine(tc.Adding(box.Get()).Value);
         tc.Add(Add3(box));
         Console.WriteLine(tc.Adding(box.Get()).Value);
         tc.Add(DoSet(box, 4.ToFuture()));
         Console.WriteLine(tc.Adding(box.Get()).Value);
     });
 }