Exemplo n.º 1
0
 public static OneShotDispatcherTimer CreateAndStart(TimeSpan duration, EventHandler callback)
 {
     var timer = new OneShotDispatcherTimer {Duration = duration};
     timer.Fired += callback;
     timer.Start();
     return timer;
 }
Exemplo n.º 2
0
 private void RequestCachePruning()
 {
     lock (this)
     {
         if (_cachePruningTimer != null || _cachePruningTimestamp.Add(CachePruningInterval) >= DateTime.UtcNow)
         {
             return;
         }
         Deployment.Current.Dispatcher.BeginInvoke(() =>
             {
                 if (_cachePruningTimer != null)
                 {
                     return;
                 }
                 _cachePruningTimer = OneShotDispatcherTimer.CreateAndStart(CachePruningTimerDuration, OnCachePruningTimerFired);
             });
     }
 }
Exemplo n.º 3
0
 private void OnCachePruningTimerFired(object sender, EventArgs e)
 {
     if (sender != _cachePruningTimer)
     {
         return;
     }
     _cachePruningTimer = null;
     _cachePruningTimestamp = DateTime.UtcNow;
     ThreadPool.QueueUserWorkItem(state => PruneCache());
 }