public static ManualResetValueTaskSource <T> Completed <T>(T result, Exception error = null) { var vts = new ManualResetValueTaskSource <T>(); if (error != null) { vts.SetException(error); } else { vts.SetResult(result); } return(vts); }
public static ManualResetValueTaskSource <T> Delay <T>(int delayMs, T result, Exception error = null) { var vts = new ManualResetValueTaskSource <T>(); Task.Delay(delayMs).ContinueWith(_ => { if (error != null) { vts.SetException(error); } else { vts.SetResult(result); } }); return(vts); }