protected TReturn DoHandleOn <TArg, TReturn>(Func <TArg, Task> handlerTask, Action <TArg> handlerAction, string callerFile, int line) where TReturn : AbstractAsyncEvent { if (handlerTask == null && handlerAction == null) { return((TReturn)this); } var caller = Debugger.IsAttached ? $"{callerFile}:{line}" : string.Empty; if (handlerTask != null && !HasHandler(handlerTask)) { Handlers.Add(new AsyncEventTaskHandler <TArg> { Action = handlerTask, Event = this, Caller = caller }); } if (handlerAction != null && !HasHandler(handlerTask)) { Handlers.Add(new AsyncEventActionHandler <TArg> { Action = handlerAction, Event = this, Caller = caller }); } return((TReturn)this); }
public void Dispose() { Watcher.Add(DateTime.UtcNow.Subtract(Start)); var average = Watcher.Average(x => x.TotalSeconds).Round(2); var max = Watcher.Max(x => x.TotalSeconds).Round(2); Console.WriteLine(Action.PadRight(INDENTATION) + " Avg: " + average.ToString().PadRight(10) + " Max: " + max.ToString().PadRight(10)); }