예제 #1
0
 public static OneShotDispatcherTimer CreateAndStart(TimeSpan duration, EventHandler callback)
 {
     var timer = new OneShotDispatcherTimer {Duration = duration};
     timer.Fired += callback;
     timer.Start();
     return timer;
 }
예제 #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);
             });
     }
 }
예제 #3
0
 private void OnCachePruningTimerFired(object sender, EventArgs e)
 {
     if (sender != _cachePruningTimer)
     {
         return;
     }
     _cachePruningTimer = null;
     _cachePruningTimestamp = DateTime.UtcNow;
     ThreadPool.QueueUserWorkItem(state => PruneCache());
 }