コード例 #1
0
ファイル: SqlStatementManager.cs プロジェクト: lvshiling/Scut
 /// <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();
     }
 }
コード例 #2
0
ファイル: MathTest.cs プロジェクト: LeeWangyeol/Scut
        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);
        }