C# 定时器定时更新
生活随笔
收集整理的這篇文章主要介紹了
C# 定时器定时更新
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
class Program{static void Main(string[] args){//for (int i = 0; i < 100; i++)//{// SendMessage("131", "131");//}System.Timers.Timer aTimer = new System.Timers.Timer();aTimer.Elapsed += new ElapsedEventHandler(aTimer_Elapsed);// 設置引發時間的時間間隔 此處設置為1秒(1000毫秒)aTimer.Interval = 300; //設置時間間隔aTimer.Enabled = true;Console.WriteLine("按回車鍵結束程序");Console.WriteLine(" 等待程序的執行......");Console.ReadLine();//SendMessage("131", "131");}static void aTimer_Elapsed(object sender, ElapsedEventArgs e){SendMessage("131", "131");}private static void SendMessage(string PhoneNum, string Message){try{using (ServiceReference1.WcfServiceClient sum = new ConsoleApplication1.ServiceReference1.WcfServiceClient()){ServiceReference1.MessageOk ok = new ConsoleApplication1.ServiceReference1.MessageOk();ok.Message = Message;ok.Phone = PhoneNum;ServiceReference1.MessageOk NewMessage = sum.Ok(ok);Console.WriteLine(NewMessage.Message);Console.WriteLine("22");//Console.ReadLine();}}catch(Exception e){Console.WriteLine(e.ToString());Console.ReadKey();}}}
轉載于:https://www.cnblogs.com/happygx/archive/2012/04/11/2442724.html
總結
以上是生活随笔為你收集整理的C# 定时器定时更新的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 比ofo良心!美团回应摩拜单车退押金:2
- 下一篇: [JSOI2008 Prefix火星人]