Example #1
0
        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());
            }
        }
Example #2
0
        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);
        }
Example #4
0
        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);
                });
            }
        }
Example #5
0
 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());
        }