文章地址:http://www.cnblogs.com/huangxincheng/archive/2011/11/13/2246934.html#2256396
System.Timers.Timer是基于.Net PoolThread实现的,独立于UI线程
public void GetService(string address) { Timer timer = new Timer(); timer.Interval = 1000; timer.Elapsed += (obj, sender) => { try { //这个是定时的检测IIS是否挂掉 var factory = new ChannelFactory<IServiceList>(new NetTcpBinding(SecurityMode.None), new EndpointAddress(address)); factory.CreateChannel().AddSearchList(search); factory.Close(); timer.Interval = 10000; } catch (Exception ex) { Console.WriteLine(ex.Message); } }; timer.Start(); }