예제 #1
0
        protected virtual void TriggerEvent(SimpleTask task, EventCallback cb = null)
        {
            TaskScheduleEvent e = new TaskScheduleEvent(task);

            if (!(task.Owner is IEventEmitter owner))
            {
                return;
            }

            IEventBus eventBus = Container.Resolve <IEventBus>();

            if (eventBus == null)
            {
                InternalTasks.Add(task);
                cb?.Invoke(owner, null);
                return;
            }

            eventBus.Emit(owner, e, @event =>
            {
                task.IsCancelled = e.IsCancelled;

                if (!e.IsCancelled)
                {
                    InternalTasks.Add(task);
                }

                cb?.Invoke(owner, @event);
            });
        }
        public virtual void TriggerEvent(UnityTask task, EventCallback cb = null)
        {
            if (task.ExecutionTarget == ExecutionTargetContext.Async || task.ExecutionTarget == ExecutionTargetContext.NextAsyncFrame ||
                task.ExecutionTarget == ExecutionTargetContext.EveryAsyncFrame)
            {
                m_AsyncThreadPool.EventWaitHandle.Set();
            }

            TaskScheduleEvent e = new TaskScheduleEvent(task);

            if (m_EventBus == null)
            {
                m_Tasks.Add(task);
                cb?.Invoke(task.Owner, null);
                return;
            }

            m_EventBus.Emit(task.Owner, e, @event =>
            {
                task.IsCancelled = e.IsCancelled;

                if (!e.IsCancelled)
                {
                    m_Tasks.Add(task);
                }

                cb?.Invoke(task.Owner, @event);
            });
        }
예제 #3
0
        private void TriggerEvent(SimpleTask task, EventCallback cb = null)
        {
            TaskScheduleEvent e = new TaskScheduleEvent(task);

            if (!(task.Owner is IEventEmitter owner))
            {
                return;
            }

            if (!task.Owner.IsAlive)
            {
                return;
            }

            IEventManager eventManager = container.Resolve <IEventManager>();

            eventManager?.Emit(owner, e, @event =>
            {
                task.IsCancelled = e.IsCancelled;

                if (!e.IsCancelled)
                {
                    tasks.Add(task);
                }

                cb?.Invoke(owner, @event);
            });
        }