Merge pull request #310 from PepperDash/hotfix/program-initialization

Update ControlSystem to control program startup for subsequent programs better
This commit is contained in:
Andrew Welker
2020-07-08 10:54:51 -07:00
committed by GitHub

View File

@@ -35,6 +35,7 @@ namespace PepperDash.Essentials
Thread.MaxNumberOfUserThreads = 400; Thread.MaxNumberOfUserThreads = 400;
Global.ControlSystem = this; Global.ControlSystem = this;
DeviceManager.Initialize(this); DeviceManager.Initialize(this);
SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true;
} }
/// <summary> /// <summary>
@@ -90,7 +91,12 @@ namespace PepperDash.Essentials
if (!Debug.DoNotLoadOnNextBoot) if (!Debug.DoNotLoadOnNextBoot)
{
GoWithLoad(); GoWithLoad();
return;
}
SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true;
} }
/// <summary> /// <summary>
@@ -168,7 +174,7 @@ namespace PepperDash.Essentials
public void GoWithLoad() public void GoWithLoad()
{ {
try try
{ {
Debug.SetDoNotLoadOnNextBoot(false); Debug.SetDoNotLoadOnNextBoot(false);
PluginLoader.AddProgramAssemblies(); PluginLoader.AddProgramAssemblies();
@@ -188,11 +194,14 @@ namespace PepperDash.Essentials
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Folder structure verified. Loading config..."); Debug.Console(0, Debug.ErrorLogLevel.Notice, "Folder structure verified. Loading config...");
if (!ConfigReader.LoadConfig2()) if (!ConfigReader.LoadConfig2())
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Essentials Load complete with errors");
return; return;
}
Load(); Load();
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Essentials load complete\r" + Debug.Console(0, Debug.ErrorLogLevel.Notice, "Essentials load complete\r\n" +
"-------------------------------------------------------------"); "-------------------------------------------------------------");
} }
else else
{ {
@@ -211,11 +220,13 @@ namespace PepperDash.Essentials
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e); Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r\n{0}", e);
}
finally
{
// Notify the OS that the program intitialization has completed
SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true;
} }
// Notify the OS that the program intitialization has completed
SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true;
} }