|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using NLog;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Common.Eventing
|
|
|
|
@ -20,11 +21,25 @@ namespace NzbDrone.Common.Eventing
|
|
|
|
|
{
|
|
|
|
|
_logger.Trace("Publishing {0}", message.GetType().Name);
|
|
|
|
|
|
|
|
|
|
//call synchronous handlers first.
|
|
|
|
|
foreach (var handler in _handlers().OfType<IHandle<TEvent>>())
|
|
|
|
|
{
|
|
|
|
|
_logger.Trace("{0} => {1}", message.GetType().Name, handler.GetType().Name);
|
|
|
|
|
_logger.Debug("{0} -> {1}", message.GetType().Name, handler.GetType().Name);
|
|
|
|
|
handler.Handle(message);
|
|
|
|
|
_logger.Debug("{0} -#> {1}", message.GetType().Name, handler.GetType().Name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var handler in _handlers().OfType<IHandleAsync<TEvent>>())
|
|
|
|
|
{
|
|
|
|
|
var handlerLocal = handler;
|
|
|
|
|
Task.Factory.StartNew(() =>
|
|
|
|
|
{
|
|
|
|
|
_logger.Debug("{0} ~> {1}", message.GetType().Name, handlerLocal.GetType().Name);
|
|
|
|
|
handlerLocal.HandleAsync(message);
|
|
|
|
|
_logger.Debug("{0} ~#> {1}", message.GetType().Name, handlerLocal.GetType().Name);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|