Beispiel #1
0
 /// <summary>
 /// Constructs an asynchronous computation that runs the given computation and ignores its result.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="m"></param>
 /// <returns></returns>
 public static Async <Unit> Ignore <T>(this Async <T> m)
 {
     return(() =>
     {
         m.RunSynchronously();
         return Unit.Default;
     });
 }
Beispiel #2
0
 public Unit Enqueue(Async <Unit> a)
 {
     ThreadPool.QueueUserWorkItem(_ => {
         try
         {
             a.RunSynchronously();
         }catch (Exception e)
         {
             Async.DispatchException(e);
         }
     });
     return(Unit.Default);
 }
Beispiel #3
0
 /// <summary>
 /// Applies f to the result of m
 /// </summary>
 /// <typeparam name="TInput"></typeparam>
 /// <typeparam name="TOutput"></typeparam>
 /// <param name="m"></param>
 /// <param name="f"></param>
 /// <returns></returns>
 public static Async <TOutput> Bind <TInput, TOutput>(this Async <TInput> m, Func <TInput, Async <TOutput> > f)
 {
     return(() => f(m.RunSynchronously()).RunSynchronously());
 }