Esempio n. 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);
            });
        }
Esempio n. 2
0
        protected virtual void TriggerEvent(ScheduledTask task, EventCallback cb = null)
        {
            if (task.ExecutionTarget == ExecutionTargetContext.Async ||
                task.ExecutionTarget == ExecutionTargetContext.NextAsyncFrame ||
                task.ExecutionTarget == ExecutionTargetContext.EveryAsyncFrame)
            {
                asyncTaskRunner.NotifyTaskScheduled();
            }

            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, async @event =>
            {
                task.IsCancelled = e.IsCancelled;

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

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