public bool CancelTask(ITask t) { SimpleTask task = (SimpleTask)t; task.IsCancelled = true; return(tasks.Remove(task)); }
public ITask ScheduleNextAsyncFrame(ILifecycleObject @object, Action action, string taskName) { SimpleTask task = new SimpleTask(this, @object, action, ExecutionTargetContext.NextAsyncFrame); TriggerEvent(task); return(task); }
public ITask ScheduleEveryPhysicUpdate(ILifecycleObject @object, Action action, string taskName) { SimpleTask task = new SimpleTask(this, @object, action, ExecutionTargetContext.EveryPhysicsUpdate); TriggerEvent(task); return(task); }
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); }); }
public ITask ScheduleUpdate(ILifecycleObject @object, Action action, string taskName, ExecutionTargetContext target) { SimpleTask task = new SimpleTask(this, @object, action, target); TriggerEvent(task, (sender, @event) => { if (target != ExecutionTargetContext.Sync && @object.IsAlive) { return; } if (((ICancellableEvent)@event).IsCancelled) { return; } action(); tasks.Remove(task); }); return(task); }