示例#1
0
 /// <summary>
 /// 线程切换检测
 /// </summary>
 private static void check()
 {
     if (TcpInternalServer.ServerSocketTaskConfig.Default.IsCheck(Task.currentTaskTicks))
     {
         if (isAllTask)
         {
             if (++taskIndex == tasks.Length)
             {
                 taskIndex = 0;
             }
             Task = tasks[taskIndex];
         }
         else
         {
             try
             {
                 Task = new ServerSocketTask(TcpInternalServer.ServerSocketTaskConfig.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 ServerSocketTask()
 {
     TcpInternalServer.ServerSocketTaskConfig config = TcpInternalServer.ServerSocketTaskConfig.Default;
     if (config.ThreadCount == 1)
     {
         Task = new ServerSocketTask(0);
     }
     else
     {
         tasks    = new ServerSocketTask[config.ThreadCount];
         tasks[0] = Task = new ServerSocketTask(config.TaskTicks);
         config.OnCheck(check);
     }
 }