/// <summary>Runs a delegate in a seperate thread.</summary> /// <param name="run">The delegate to run in the background with reporting.</param> /// <param name="report">The delegate for reporting</param> /// <param name="resolve">The delegate for handling the completion of the background thread.</param> public static IAsyncResult Thread( OperationReport run, Callback report, Resolve resolve) { if (run == null) { throw new System.ArgumentNullException("run"); } if (report == null) { throw new System.ArgumentNullException("report"); } if (resolve == null) { throw new System.ArgumentNullException("resolve"); } SynchronizationContext context = SynchronizationContext.Current; return(run.BeginInvoke( () => { context.Post((object state) => { report(); }, null); }, (IAsyncResult ar) => { context.Post((object state) => { resolve(ar); }, null); }, null)); }
/// <summary>Runs a delegate in a seperate thread.</summary> /// <param name="run">The delegate to run in the background with reporting.</param> /// <param name="report">The delegate for reporting</param> public static IAsyncResult Thread( OperationReport run, Callback report) { if (run is null) { throw new ArgumentNullException(nameof(run)); } if (report is null) { throw new ArgumentNullException(nameof(report)); } SynchronizationContext context = SynchronizationContext.Current; return(run.BeginInvoke( () => { context.Post((object state) => { report(); }, null); }, (IAsyncResult ar) => { }, null)); }