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

            if (config.ThreadCount == 1)
            {
                Task = new ClientCallTask(0);
            }
            else
            {
                tasks    = new ClientCallTask[config.ThreadCount];
                tasks[0] = Task = new ClientCallTask(config.TaskTimestamp);
                config.OnCheck(check);
            }
        }