Server端代码:
class Program
{
static SocketListener listener;
public static void Main(string[] args)
{
//实例化Timer类,设置间隔时间为5000毫秒;
System.Timers.Timer t = new System.Timers.Timer(5000);
t.Elapsed += new System.Timers.ElapsedEventHandler(CheckListen);
//到达时间的时候执行事件;
t.AutoReset