private static void RegisterFaultHandler(IDataflowBlock block, UnconfiguredProject project, ProjectFaultSeverity severity) { IProjectFaultHandlerService faultHandlerService = project.Services.FaultHandler; Task faultTask = faultHandlerService.RegisterFaultHandler(block, project, severity); // We don't actually care about the result of reporting the fault if one occurs faultHandlerService.Forget(faultTask, project); }
/// <summary> /// Attaches error handling to a task so that if it throws an unhandled exception, /// the error will be reported to the user. /// </summary> /// <param name="faultHandlerService"> /// The <see cref="IProjectFaultHostHandler"/> that should handle the fault. /// </param> /// <param name="task"> /// The task to attach error handling to. /// </param> /// <param name="project"> /// The project related to the failure, if applicable. Can be <see langword="null"/>. /// </param> /// <param name="severity"> /// The severity of the failure. /// </param> public static void Forget <TResult>( this IProjectFaultHandlerService faultHandlerService, Task <TResult> task, UnconfiguredProject?project, ProjectFaultSeverity severity = ProjectFaultSeverity.Recoverable) { Requires.NotNull(faultHandlerService, nameof(faultHandlerService)); faultHandlerService.RegisterFaultHandler(task, s_defaultReportSettings, severity, project); }