?? recprocthread.cs
字號:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
using MonitorSystem.LogFileModule;
using MonitorSystem.BasicClass;
namespace MonitorSystem.MonitorCenter
{
/// <summary>
/// RecordProcessThread 的摘要說明。
/// </summary>
public class RecProcThread
{
private Thread m_Thread;
private bool m_Pause;
private bool m_Exit;
private RecordQueue m_queRecord;
private ConfigFile m_CfgFile;
private SystemLog m_SysLog;
private DateTime CreateTime;
public void Init(ref RecordQueue iRecordQueue, ref ConfigFile iConfigFile)
{
this.m_queRecord = iRecordQueue;
this.m_CfgFile = iConfigFile;
this.m_SysLog = new SystemLog();
CreateTime = new DateTime(2004,1,1,0,0,0);
}
public void Run()
{
string sqlConn = m_CfgFile.ConnectionStr;
while(true)
{
while(m_Pause)
{
try
{
Thread.Sleep(1000);
}
catch(Exception)
{
}
continue;
}
if(m_Exit)
{
break;
}
if (m_queRecord.Count <= 0)
{
try
{
Thread.Sleep(1000);
continue;
}
catch(Exception)
{
continue;
}
}
LogFile log = new LogFile();
log = (LogFile)m_queRecord.Dequeue();
try
{
int nRet=log.WriteToDB(sqlConn,m_CfgFile.LogTableName,m_CfgFile.AlertTableName);
if(nRet!=0)
{
m_SysLog.WriteToSysLog("該記錄插入監(jiān)控日志表失敗");
}
}
catch(Exception error1)
{
m_SysLog.WriteToSysLog("該記錄插入監(jiān)控日志表失敗,原因:{0}",error1.Message);
}
try
{
Thread.Sleep(100);
}
catch(Exception)
{
}
}
}
public void Startup()
{
m_Thread = new Thread(new ThreadStart(this.Run));
// Start the thread
m_Pause = false;
m_Exit = false;
m_Thread.Start();
}
public void Join()
{
if(m_Thread != null)
{
m_Thread.Interrupt();
m_Thread.Join();
}
else
{
return;
}
}
public bool IsAlive()
{
if(m_Thread != null)
{
return m_Thread.IsAlive;
}
else
{
return false;
}
}
public void Suspend()
{
if(m_Pause == false)
m_Pause = true;
}
public void Resume()
{
if(m_Pause == true)
m_Pause = false;
}
public void SetExit()
{
if(m_Exit == false)
m_Exit = true;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -