refactor Scheduler to use new BackgroundTaskRunner capabilities
Conflicts: src/Umbraco.Web/Scheduling/Scheduler.cs
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user