public static Task <Result <T, E> > CheckIf <T, K, E>(this Result <T, E> result, bool condition, Func <T, Task <Result <K, E> > > func) { if (condition) { return(result.Check(func)); } else { return(Task.FromResult(result)); } }
public static Task <Result <T, E> > CheckIf <T, K, E>(this Result <T, E> result, Func <T, bool> predicate, Func <T, Task <Result <K, E> > > func) { if (result.IsSuccess && predicate(result.Value)) { return(result.Check(func)); } else { return(Task.FromResult(result)); } }
static TaskUtils() { var src = new TaskCompletionSource <Object>(); src.SetResult(null); CompletedTask = src.Task; True = TTaskExt.FromResult(true); False = TTaskExt.FromResult(false); }
public static Task <T> AsCompletedTask <T>(this T obj) => Task.FromResult(obj);
public Task <int> NonAsyncGenericTask() { return(Task.FromResult(1)); }
public async Task <int> AsyncGenericTask() { return(await Task.FromResult(1)); }
public AsyncLock() { m_releaser = TaskEx.FromResult((IDisposable) new Releaser(this)); }