C#常用方法

定时器

1 System.Threading.TimerCallback tcb = new System.Threading.TimerCallback(RefreshTimer_Callback);
2 _RefreshTimer = new System.Threading.Timer(tcb, null, 5 * 100, _Global.Sys_Info.RefreshTime * 1000);
定时线程

 

垃圾回收

 1         private void StartGCCollect()
 2         {
 3             System.Windows.Forms.Timer gcTimer = new Timer();
 4             gcTimer.Interval = 5 * 60 * 1000;
 5             gcTimer.Tick += new EventHandler(gcTimer_Tick);
 6             gcTimer.Start();
 7         }
 8 
 9         private void gcTimer_Tick(object sender, EventArgs e)
10         {
11             try
12             {
13                 GC.Collect();
14             }
15             catch (Exception ex)
16             {
17                 _Global.RecordExceptionInfo("强制对所有代进行垃圾回收函数异常", ex);
18             }
19         }
垃圾回收

 

posted @ 2016-08-03 11:39  凝荷  阅读(230)  评论(0编辑  收藏  举报