Пример #1
0
 /// <summary>
 /// 线程切换检测
 /// </summary>
 private static void check()
 {
     if (TcpServer.TaskConfig.Default.IsCheck(Task.currentTaskTicks))
     {
         if (isAllTask)
         {
             if (++taskIndex == tasks.Length)
             {
                 taskIndex = 0;
             }
             Task = tasks[taskIndex];
         }
         else
         {
             try
             {
                 Task = new OnSendTask(TcpServer.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);
             }
         }
     }
 }
Пример #2
0
 static OnSendTask()
 {
     TcpServer.TaskConfig config = TcpServer.TaskConfig.Default;
     if (config.ThreadCount == 1)
     {
         Task = new OnSendTask(0);
     }
     else
     {
         tasks    = new OnSendTask[config.ThreadCount];
         tasks[0] = Task = new OnSendTask(config.TaskTicks);
         config.OnCheck(check);
     }
 }