public static IAsync <T> BeginEval <T>(this IAsyncWorkQueue queue, Func <T> f) { IAsyncSource <T> source = Async.NewSource <T>(); queue.BeginTry(delegate { try { Result <T> result = f.Eval <T>(); source.SetResult(result); } catch (Exception exception) { source.Throw <T>(new TargetInvocationException(exception)); } }); return(source.AsReceiveOnly <T>()); }
public static IAsync BeginTry <T1>(this IAsyncWorkQueue queue, Action <T1> f, T1 arg1) => queue.BeginTry(delegate { f(arg1); });