Fix BackgroundTaskRunner for tests without an app context
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user