public class SerialClass:MSCommLib.MSCommClass
{
#region 常量、变量声明
//成员变量声明
private System.Timers.Timer T;
//事件
public delegate void tmpDelegate();
public event tmpDelegate My_OnComm;
#endregion
#region 构造函数
public SerialClass(short TimeInterval)
{
T = new System.Timers.Timer();
T.Interval = TimeInterval;
T.Elapsed +=new System.Timers.ElapsedEventHandler(T_Elapsed);
}
#endregion
#region Timer操作
public void Start()
{
T.Start();
}
public void Stop()
{
T.Stop();
}
#endregion
#region 发送消息
private void T_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (InBufferCount<=0) return;
My_OnComm();
}
#endregion
}
本文地址:http://com.8s8s.com/it/it42130.htm