コード例 #1
0
 protected virtual void Dispose(bool disposing)
 {
     if (entry != null)
     {
         entry.Dispose();
         entry = null;
     }
     if (timer != null)
     {
         timer.Dispose();
         timer = null;
     }
 }
コード例 #2
0
 public ThreadTimer(Fun0 <Unit> cb, int ms)
 {
     entry = Primitive.GetEventloopEntry();
     if (ms <= 0)
     {
         timer = null;
         entry.Post(() => { cb.Apply(); });
     }
     else
     {
         timer = new Timer((object state0) => {
             if (entry != null)
             {
                 entry.Post(() => { cb.Apply(); });
             }
         }, null, ms, Timeout.Infinite);
     }
 }
コード例 #3
0
 public _DownloadText(string uri, double timeout, Fun2 <Exception, string, Unit> cb)
 {
     entry     = Primitive.GetEventloopEntry();
     webClient = new System.Net.WebClient();
     try {
         webClient.DownloadStringCompleted += (object sender, System.Net.DownloadStringCompletedEventArgs e) => {
             if (entry != null)
             {
                 entry.Post(() => cb.Call(e.Error, (e.Error != null ? "" : e.Result)));
                 entry = null;
             }
             Dispose();
         };
         webClient.DownloadStringAsync(new Uri(uri));
     }
     catch (Exception exn) {
         Dispose();
         throw exn;
     }
 }
コード例 #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposing)
     {
         return;
     }
     if (webClient != null)
     {
         if (entry != null)
         {
             webClient.CancelAsync();
         }
         webClient.Dispose();
         webClient = null;
     }
     if (entry != null)
     {
         entry.Dispose();
         entry = null;
     }
 }