/// <inheritdoc /> public ThreadSafeTask(int taskId, string name, ITaskScheduler scheduler, ILifecycleObject owner, Action action, ExecutionTargetContext executionTargetContext) { TaskId = taskId; Name = name; Scheduler = scheduler; Owner = owner; Action = action; ExecutionTarget = executionTargetContext; }
internal ScheduledTask(int taskId, string taskName, ITaskScheduler scheduler, ILifecycleObject owner, Action action, ExecutionTargetContext executionTarget) { Name = taskName; ownerRef = new Core.Util.WeakReference <ILifecycleObject>(owner); Action = action; ExecutionTarget = executionTarget; Scheduler = scheduler; TaskId = taskId; }
internal SimpleTask(int taskId, string taskName, ITaskScheduler scheduler, ILifecycleObject owner, Action action, ExecutionTargetContext executionTarget) { Name = taskName; Owner = owner; Action = action; ExecutionTarget = executionTarget; Scheduler = scheduler; TaskId = taskId; }
internal SimpleTask(ITaskScheduler scheduler, ILifecycleObject owner, Action action, ExecutionTargetContext executionTarget) { Owner = owner; Action = action; ExecutionTarget = executionTarget; Scheduler = scheduler; TaskId = ++taskIds; }
public UnityTask(int taskId, string name, UnityTaskScheduler scheduler, object owner, Action action, ExecutionTargetContext executionTargetContext) { TaskId = taskId; Name = name; Scheduler = scheduler; Owner = owner; Action = action; ExecutionTarget = executionTargetContext; }
/// <inheritdoc /> public ITask ScheduleAt(ILifecycleObject @object, Action action, string taskName, DateTime date, bool runAsync = false) { ThreadSafeTask task; ExecutionTargetContext context = runAsync ? ExecutionTargetContext.Async : ExecutionTargetContext.NextFrame; lock (taskIdLock) { task = new ThreadSafeTask(taskId++, taskName, this, @object, action, context, TimeSpan.Zero, date, null); } lock (lockObj) { tasks.Add(task); } return(task); }
/// <inheritdoc /> public ITask SchedulePeriodically(ILifecycleObject @object, Action action, string taskName, TimeSpan period, TimeSpan?delay = null, bool runAsync = false) { ThreadSafeTask task; ExecutionTargetContext context = runAsync ? ExecutionTargetContext.Async : ExecutionTargetContext.NextFrame; DateTime startTime = DateTime.UtcNow; if (delay != null) { startTime = startTime.Add(delay.Value); } lock (taskIdLock) { task = new ThreadSafeTask(taskId++, taskName, this, @object, action, context, period, startTime, null); } lock (lockObj) { tasks.Add(task); } return(task); }
public virtual ITask ScheduleUpdate(object @object, Action action, string taskName, ExecutionTargetContext target) { UnityTask task = new UnityTask(++m_NextTaskId, taskName, this, @object, action, target); TriggerEvent(task, (sender, @event) => { if (target != ExecutionTargetContext.Sync) { return; } if (@event != null && ((ICancellableEvent)@event).IsCancelled) { return; } action(); m_Tasks.Remove(task); }); return(task); }
public ITask ScheduleUpdate(ILifecycleObject @object, Action action, string taskName, ExecutionTargetContext target) { SimpleTask task = new SimpleTask(++taskIds, taskName, this, @object, action, target); TriggerEvent(task, (sender, @event) => { if (target != ExecutionTargetContext.Sync && @object.IsAlive) { return; } if (@event != null && ((ICancellableEvent)@event).IsCancelled) { return; } action(); InternalTasks.Remove(task); }); return(task); }
/// <inheritdoc /> public ThreadSafeTask(int taskId, string name, ITaskScheduler scheduler, ILifecycleObject owner, Action action, ExecutionTargetContext executionTargetContext, TimeSpan?period, DateTime?startTime, DateTime?endTime) : this(taskId, name, scheduler, owner, action, executionTargetContext) { Period = period; StartTime = startTime; EndTime = endTime; }
/// <inheritdoc cref="ITaskScheduler.ScheduleUpdate"/> public static IScheduledTask ScheduleTaskUpdate(this ITaskScheduler taskScheduler, ILifecycleObject @owner, AsyncAction action, string taskName, ExecutionTargetContext frame) { return(taskScheduler.ScheduleUpdate(@owner, action().GetAwaiter().GetResult, taskName, frame)); }
/// <inheritdoc /> public ITask ScheduleUpdate(ILifecycleObject @object, Action action, string taskName, ExecutionTargetContext target) { ThreadSafeTask task; lock (taskIdLock) { task = new ThreadSafeTask(taskId++, taskName, this, @object, action, target); } lock (lockObj) { tasks.Add(task); } return(task); }
/// <inheritdoc cref="ITaskScheduler.ScheduleUpdate"/> public static IScheduledTask ScheduleTaskUpdate(this ITaskScheduler taskScheduler, ILifecycleObject @owner, AsyncAction action, string taskName, ExecutionTargetContext frame) { return(taskScheduler.ScheduleUpdate(@owner, () => AsyncHelper.RunSync(() => action()), taskName, frame)); }