Пример #1
0
 static EventLog()
 {
     thread = new ThreadWork();
     thread.Start("eventLog", () =>
     {
         WriteLogFromCache();
         return(true);
     }, 0.3);
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="objCreater">对象实例化</param>
 /// <param name="maxSize">池最大值</param>
 /// <param name="poolClearMinute">不使用时,多少分钟后清空</param>
 public SimplePool(Func <T> objCreater, int maxSize = 20, int poolClearMinute = 0)
 {
     _objCreater = objCreater;
     _maxSize    = maxSize;
     if (poolClearMinute > 0)
     {
         clearWork = new ThreadWork();
         clearWork.Start("SimplePoolClear", b =>
         {
             var ts = DateTime.Now - useTime;
             if (ts.TotalMinutes > poolClearMinute)
             {
                 Clear();
             }
             return(true);
         }, 30);
     }
 }