public OneShotDispatcherTimerPage() { InitializeComponent(); _oneShotTimer = new OneShotDispatcherTimer(); _oneShotTimer.Duration = OneShotTimerDuration; _oneShotTimer.Fired += OnOneShotTimerFired; }
private void OnCachePruningTimerFired(object sender, EventArgs e) { if (sender != _cachePruningTimer) { return; } _cachePruningTimer = null; _cachePruningTimestamp = DateTime.UtcNow; ThreadPool.QueueUserWorkItem((state) => { PruneCache(); }); }
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); }); } }