?? platformcheckthread.cs
字號:
using System;
using System.IO;
using System.Threading;
using MonitorSystem.BasicClass;
using MonitorSystem.LogFileModule;
namespace MonitorSystem.MonitorCenter
{
/// <summary>
/// PlatformCheckThread 的摘要說明。
/// </summary>
public class PlatformCheckThread
{
private Thread m_Thread;
private bool m_Pause;
private bool m_Exit;
private RecordQueue m_queRecord;
private SystemLog m_SysLog;
private ConfigFile m_CfgFile;
public PlatformCheckThread()
{
m_Pause = false;
m_Exit = false;
m_SysLog=new SystemLog();
}
public void Init(ref RecordQueue queRecord,ConfigFile iCfgFile)
{
m_queRecord = queRecord;
m_CfgFile = iCfgFile;
}
public void Run()
{
while(true)
{
while(m_Pause)
{
try
{
Thread.Sleep(1000);
}
catch(Exception)
{
}
continue;
}
if(m_Exit)
{
break;
}
try
{
//心跳檢測間隔時間
Thread.Sleep(m_CfgFile.PlatformCheckTimeSpan);
}
catch(Exception)
{
}
try
{
//檢查節點監控日志是否上傳
for(int i=0; i<CenterService.m_bPlatformCheck.Length; i++)
{
if(CenterService.m_bPlatformCheck[i]==false)
{
LogFile logRecord = new LogFile();
logRecord.iInterfaceAction = new int[1];
logRecord.strInActionParam = new String[1];
logRecord.strDateTime = System.DateTime.Now.ToString();
logRecord.iPlatformID = Convert.ToInt32(m_CfgFile.PlatformID[i]);
logRecord.iNodeID = -1;
logRecord.iTypeID = 99;
logRecord.iRuleID = 0;
logRecord.strRuleName = "平臺心跳檢測";
logRecord.strValue = "-1";
logRecord.iStatus = 4;
logRecord.iInterfaceAction[0] = 1;
logRecord.strInActionParam[0] = "";
//將記錄入待處理記錄隊列
this.m_queRecord.Enqueue(logRecord);
}
//將心跳檢測參數設為初始值
CenterService.m_bPlatformCheck[i] = false;
}
}
catch(Exception ex)
{
string msg=String.Format("平臺心跳檢查失敗:{0}",ex.Message);
m_SysLog.WriteToSysLog(msg);
}
if(m_Exit)
{
break;
}
}
}
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;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -