/// <summary> /// Wraps handler for Asynchronous execution /// </summary> /// <typeparam name="TEvent"></typeparam> /// <param name="handler"></param> /// <returns></returns> public static Delegate <TEvent> Async <TEvent>(this ICanHandle <TEvent> handler, EventBusService eventBusService = null) { Delegate <TEvent> handlerAsDelegate = handler.Handle; return(Async <TEvent>(handlerAsDelegate, eventBusService)); }
/// <summary> /// Wraps handler for Asynchronous execution /// </summary> /// <typeparam name="TEvent"></typeparam> /// <param name="handler"></param> /// <param name="eventBusService">eventBusService to use, EventBus.Default if null</param> /// <returns></returns> public static Delegate <TEvent> Async <TEvent>(this Delegate <TEvent> handler, EventBusService eventBusService = null) { return((param) => { handler.BeginInvoke(param, new AsyncCallback <TEvent>(handler, eventBusService == null ? EventBus.Default : eventBusService) .Callback, null); }); }