Ejemplo n.º 1
0
 /// <summary>
 /// Start
 /// </summary>
 public static void Start()
 {
     TraceLog.ReleaseWriteDebug("Sql write queue start init...");
     MessageQueueSection section = GetSection();
     SlaveMessageQueue = section.SlaveMessageQueue;
     if (_queueWatchTimers != null && _queueWatchTimers.Length != section.SqlSyncQueueNum)
     {
         foreach (var timer in _queueWatchTimers)
         {
             try
             {
                 timer.Dispose();
             }
             catch (Exception ex)
             {
                 TraceLog.WriteError("Sql write queue stop error:{0}", ex);
             }
         }
         _queueWatchTimers = null;
     }
     if (_queueWatchTimers == null)
     {
         _isWatchWorking = new int[section.SqlSyncQueueNum];
         _queueWatchTimers = new Timer[_isWatchWorking.Length];
         for (int i = 0; i < _queueWatchTimers.Length; i++)
         {
             _queueWatchTimers[i] = new Timer(OnCheckSqlSyncQueue, i, 100, 100);
         }
         _threadPools = new SmartThreadPool(180 * 1000, 100, 5);
         _threadPools.Start();
     }
 }
Ejemplo n.º 2
0
        public void ThreadTest()
        {
            var _threadPools = new SmartThreadPool(180 * 1000, 100, 5);
            _threadPools.Start();

            var result = _threadPools.QueueWorkItem(() =>
            {
                Thread.Sleep(5000);
            });
            while (!result.IsCompleted)
            {
                Thread.Sleep(100);
                Trace.WriteLine("wait...");
            }
            Trace.WriteLine(result.Result);
        }