static void RemoveTaskFromPool(string data) { currentExecutingTask.OnComplete -= RemoveTaskFromPool; taskPool.Remove(currentExecutingTask); currentExecutingTask = null; ExecuteFirstTask(); }
static void Init() { if (ready) { return; } savedTaskes = new List <SerializedTask>(); taskPool = new List <GameTask>(); currentExecutingTask = null; Ready(); }
static void ExecuteFirstTask() { if (taskPool.Count == 0) { if (OnScheduleFinished != null) { OnScheduleFinished.Invoke(currentScheduleID); } return; } currentExecutingTask = taskPool[0]; currentExecutingTask.OnComplete += RemoveTaskFromPool; currentExecutingTask.Execute(); }
public static string Schedule(GameTask task) { if (!ready) { Init(); } taskPool.Add(task); if (currentExecutingTask == null) { ExecuteFirstTask(); currentScheduleID = Guid.NewGuid().ToString(); } return(currentScheduleID); }
public override void Execute() { Debug.Log("____ UpdateOfflineTasks: ____"); Type type = Type.GetType(serializedTask.classType); //target type Debug.Log("type: " + type + " - data: " + serializedTask.data); object instanceObject = Activator.CreateInstance(type, new object[] { serializedTask.data }); // an instance of target type gameTask = (GameTask)instanceObject; gameTask.id = serializedTask.id; gameTask.SetAdditionalData(serializedTask.additionalData); gameTask.executionTime = DateTime.Parse(serializedTask.executionTime); gameTask.OnComplete += MoveNext; gameTask.OnError += RetryTask; gameTask.Execute(); }
void SaveTask(GameTask task) { if (!ready) { Init(); } Debug.Log("Saving Task"); if (savedTaskes == null) { savedTaskes = new List <SerializedTask>(); } savedTaskes.Add(new SerializedTask() { id = task.id, classType = task.GetType().FullName, data = task.GetData(), additionalData = task.additionalData, executionTime = task.executionTime.ToString(), }); SaveAllTasks(savedTaskes); }