protected override void ProcessPublish(BasePostManEvent postManEvent) { List <Task> taskPool = new List <Task>(); var currentSubscribes = ListSubscribesFor(postManEvent); if (currentSubscribes != null) { Parallel.ForEach(currentSubscribes, s => { var sync = !(s is AsyncSyncSubscribe) || (s as AsyncSyncSubscribe).Type == AsyncSyncEventType.Sync; postManEvent.ProcessingFor(s); if (sync) { taskPool.Add(Task.Run(() => { Process(postManEvent, s); })); } else { Task.Run(() => { Process(postManEvent, s); }); } }); taskPool.ForEach(t => t.Wait()); } }
private void Process(BasePostManEvent postManEvent) { this.postManEvent.Add(postManEvent); foreach (var h in hubEvents) { h.Publish(postManEvent); } }
public virtual void Publish(BasePostManEvent postManEvent) { events.Add(postManEvent); if (!HasSubscribe(postManEvent.GetType())) { return; } ProcessPublish(postManEvent); }
protected override void ProcessPublish(BasePostManEvent postManEvent) { var currentSubscribes = ListSubscribesFor(postManEvent); if (currentSubscribes != null) { Parallel.ForEach(currentSubscribes, s => { postManEvent.ProcessingFor(s); s.Published(postManEvent); postManEvent.ProcessedFor(s); }); } }
public static void Raise(BasePostManEvent postManEvent) { Instance.Process(postManEvent); }
protected abstract void ProcessPublish(BasePostManEvent postManEvent);
protected List <IPostManSubscribe> ListSubscribesFor(BasePostManEvent postManEvent) { var subscribesList = subscribes[postManEvent.GetType()]; return(subscribesList.Select(s => (IPostManSubscribe)resolver.GetSubscribe(s)).ToList()); }