/// <summary> /// Invokes the factory, using the source as input, suppressing any thrown exception. /// </summary> /// <param name="default">The result value when not successful.</param> public static Attempt <TResult> AttemptGet <TSource, TResult>(this TSource source, Func <TSource, TResult> factory, TResult @default = default(TResult)) { return(Attempt.Get(() => factory(source))); }
/// <summary> /// Invokes the factory, using the source as input, suppressing any thrown exception. /// </summary> /// <param name="default">The result value when not successful.</param> public static Task <Attempt <TResult> > AttemptGetAsync <TSource, TResult>(this TSource source, Func <TSource, Task <TResult> > factory, TResult @default = default(TResult)) { return(Attempt.GetAsync(() => factory(source))); }
public static Task <T> StartNew <T>(this TaskFactory taskFactory, Func <T> function, CancellationToken cancellationToken, TaskCreationOptions creationOptions) { var taskScheduler = Attempt.Get(TaskScheduler.FromCurrentSynchronizationContext).Value ?? TaskScheduler.Default; return(taskFactory.StartNew(function, cancellationToken, creationOptions, taskScheduler)); }