myTimer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Messaging;
using System.Timers;
using Logger;

namespace Untitly
{
   public   class myTimer
    {
    
       public static  System.Timers.Timer timers;
       public   myTimer()
       {
           
       }
       public void time() {
           timers = new System.Timers.Timer(10000);
           timers.Elapsed += new ElapsedEventHandler(myTimer_Elapsed);
           timers.Enabled = true;
           timers.AutoReset = true;
       }
       public delegate string GetLogDelegate();
       private static string GetLogs()
       {

           return DateTime.Now.ToString();
       }
       private static  void LogTableCallBack(IAsyncResult tag)
       {
           AsyncResult result = (AsyncResult)tag;
           GetLogDelegate del = (GetLogDelegate)result.AsyncDelegate;
           Test.Write(del.EndInvoke(tag));

       }

      static  void myTimer_Elapsed(object source, ElapsedEventArgs e)
       {
           try
           {
               GetLogDelegate getLogDel = new GetLogDelegate(GetLogs);

               getLogDel.BeginInvoke(new AsyncCallback(LogTableCallBack), null);
           }
           catch (Exception ex)
           {
               Log.WriteErrorLog(ex);
           }
       }
    }
}

  

posted on 2012-08-08 13:53  sajiao  阅读(433)  评论(0编辑  收藏  举报

导航

街边网