Example #1
0
 /// <summary>
 /// 添加任务
 /// </summary>
 /// <param name="value"></param>
 internal void Add(LinkQueueTaskNode value)
 {
     while (System.Threading.Interlocked.CompareExchange(ref queueLock, 1, 0) != 0)
     {
         AutoCSer.Threading.ThreadYield.Yield(AutoCSer.Threading.ThreadYield.Type.SqlLinkQueueTaskPush);
     }
     if (head == null)
     {
         head = end = value;
     }
     else
     {
         end.LinkNext = value;
         end          = value;
     }
     queueLock = 0;
     if (System.Threading.Interlocked.CompareExchange(ref isThread, 1, 0) == 0)
     {
         try
         {
             threadPool.FastStart(run);
         }
         catch (Exception error)
         {
             AutoCSer.Log.Pub.Log.Add(Log.LogType.Error, error);
             run();
         }
     }
 }
Example #2
0
 /// <summary>
 /// 添加任务
 /// </summary>
 /// <param name="value"></param>
 internal void Add(LinkQueueTaskNode value)
 {
     queueLock.EnterYield();
     if (head == null)
     {
         head = end = value;
     }
     else
     {
         end.LinkNext = value;
         end          = value;
     }
     queueLock.Exit();
     if (System.Threading.Interlocked.CompareExchange(ref isThread, 1, 0) == 0)
     {
         try
         {
             threadPool.FastStart(run);
         }
         catch (Exception error)
         {
             AutoCSer.LogHelper.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
             run();
         }
     }
 }