refactor Scheduler to use new BackgroundTaskRunner capabilities

Conflicts:
	src/Umbraco.Web/Scheduling/Scheduler.cs
This commit is contained in:
Stephan
2015-02-06 18:10:19 +01:00
committed by Shannon
parent b7436dc55f
commit a73b7a5849
6 changed files with 113 additions and 118 deletions

View File

@@ -34,12 +34,18 @@ namespace Umbraco.Web.Scheduling
if (_gate != null) return _gate;
_gate = new ManualResetEvent(false);
// note
// must use the single-parameter constructor on Timer to avoid it from being GC'd
// read http://stackoverflow.com/questions/4962172/why-does-a-system-timers-timer-survive-gc-but-not-system-threading-timer
_timer = new Timer(_ =>
{
_timer.Dispose();
_timer = null;
_gate.Set();
}, null, _delayMilliseconds, 0);
});
_timer.Change(_delayMilliseconds, 0);
return _gate;
}
}