Fix BackgroundTaskRunner for tests without an app context

This commit is contained in:
Stephan
2016-09-29 13:53:35 +02:00
parent 37d8b71d5d
commit 79623a8a67

View File

@@ -112,12 +112,15 @@ namespace Umbraco.Web.Scheduling
if (options.Hosted)
HostingEnvironment.RegisterObject(this);
if (mainDomRelease != null)
if (mainDomInstall != null || mainDomRelease != null)
{
var mainDom = ApplicationContext.Current.MainDom;
var appContext = ApplicationContext.Current;
var mainDom = appContext == null ? null : appContext.MainDom;
var reg = mainDom == null || ApplicationContext.Current.MainDom.Register(mainDomInstall, mainDomRelease);
if (reg == false)
_isCompleted = _terminated = true;
_isCompleted = _terminated = true;
if (reg && mainDom == null && mainDomInstall != null)
mainDomInstall();
}
if (options.AutoStart && _terminated == false)