/// <summary> /// 线程切换检测 /// </summary> private static void check() { if (TaskConfig.Default.IsCheck(Task.currentTaskTicks)) { if (isAllTask) { if (++taskIndex == tasks.Length) { taskIndex = 0; } Task = tasks[taskIndex]; } else { try { Task = new ServerCallTask(TaskConfig.Default.TaskTicks); tasks[++taskIndex] = Task; if (taskIndex + 1 == tasks.Length) { isAllTask = true; } } catch (Exception error) { AutoCSer.Log.Pub.Log.Add(Log.LogType.Error, error); } } } }
static ServerCallTask() { TaskConfig config = TaskConfig.Default; if (config.ThreadCount == 1) { Task = new ServerCallTask(0); } else { tasks = new ServerCallTask[config.ThreadCount]; tasks[0] = Task = new ServerCallTask(config.TaskTicks); config.OnCheck(check); } }