public static async ValueTask <T> CatchAwait <T, TException>(this ValueTask <T> task, Func <TException, ValueTask <T>, ValueTask <T> > onFailure) where TException : Exception { try { return(await(task = task.Preserve())); } catch (TException e) { return(await onFailure(e, task)); } }
public static async ValueTask CatchAwait <TException>(this ValueTask task, Func <TException, ValueTask, ValueTask> onFailure) where TException : Exception { try { await(task = task.Preserve()); } catch (TException e) { await onFailure(e, task); } }
public static async ValueTask <T> Catch <T>(this ValueTask <T> task, Func <Exception, ValueTask <T>, T> onFailure) { try { return(await(task = task.Preserve())); } catch (Exception e) { return(onFailure(e, task)); } }
public static async ValueTask Catch(this ValueTask task, Action <Exception, ValueTask> onFailure) { try { await(task = task.Preserve()); } catch (Exception e) { onFailure(e, task); } }
public ValueTask <bool> MoveNextAsync() { ValueTask <bool> valueTask = m_Source.MoveNextAsync(); ValueTask <bool> ret = valueTask.Preserve(); Current = m_Selector(Task.Run(async() => { await valueTask; return(m_Source.Current); })); return(ret); }
public static async ValueTask FinallyAwait(this ValueTask task, Func <ValueTask, ValueTask> onCompletion) { try { await(task = task.Preserve()); } finally { await onCompletion(task); } }
public static async ValueTask <T> FinallyAwait <T>(this ValueTask <T> task, Func <ValueTask <T>, ValueTask> onCompletion) { try { return(await(task = task.Preserve())); } finally { await onCompletion(task); } }
public static async ValueTask <T> Finally <T>(this ValueTask <T> task, Action <ValueTask <T> > onCompletion) { try { return(await(task = task.Preserve())); } finally { onCompletion(task); } }
public static async ValueTask <T> OnFailure <T, TException>(this ValueTask <T> task, Action <TException, ValueTask <T> > onFailure) where TException : Exception { try { return(await(task = task.Preserve())); } catch (TException e) { onFailure(e, task); throw; } }
public static async ValueTask <T> OnFailureAwait <T>(this ValueTask <T> task, Func <Exception, ValueTask <T>, ValueTask> onFailure) { try { return(await(task = task.Preserve())); } catch (Exception e) { await onFailure(e, task); throw; } }
/// <summary> /// Consumes a ValueTask and allows it to be recycled, if applicable. Useful for fire-and-forget calls to async methods within async methods. /// NOTE: APIs should not generally return <see cref="ValueTask{T}"/> if callers aren't 99.9999% likely to await the result immediately. /// </summary> /// <typeparam name="T">The type of value produced by the <paramref name="task"/>.</typeparam> /// <param name="task">The task whose result is to be ignored.</param> public static void Forget <T>(this ValueTask <T> task) => task.Preserve();
public static void Forget(this ValueTask task) { task.Preserve(); }
public static void Forget(this ValueTask valueTask) => valueTask.Preserve();