public abstract Schedule ( System.Action run ) : void | ||
run | System.Action | The run. |
Résultat | void |
/// <summary> /// Schedules the specified run and returns a continuation task. /// </summary> public static Task <T> ScheduleAsync <T>(this MessageDispatcher dispatcher, Func <T> fn) { var promise = new TaskCompletionSource <T>(); dispatcher.Schedule(() => { try { var result = fn(); promise.SetResult(result); } catch (Exception e) { promise.SetException(e); } }); return(promise.Task); }
protected override void Warmup(MessageDispatcher dispatcher) { var warmupCount = 10L; var warmupsThusFar = 0L; Action warmupWork = () => { if (Interlocked.Increment(ref warmupsThusFar) == warmupCount) { EventBlock.Set(); } }; for (var i = 0; i < warmupCount;) { dispatcher.Schedule(warmupWork); ++i; } EventBlock.Wait(); EventBlock.Reset(); }