Files
cms_thermo_active/Step/program.cs
T
Lucio Maranta 5bd278fa69 * Added NC comunication
* Added NC handler class
* Fixed threads
* Added threads: AXES, ALARMS, GENERIC INFO + API
* Refactoring
2017-12-20 17:17:02 +01:00

65 lines
1.7 KiB
C#

using Microsoft.Owin.Hosting;
using Step.UI;
using System.Threading;
using TeamDev.SDK.MVVM;
using Step.Config;
using static Step.Config.StartupConfig;
using static Step.Utils.StepLogger;
using static Step.Utils.Constants;
using Step.Database;
using Step.Core;
using Step.Listeners;
using System;
namespace Step
{
public class Application
{
public static readonly ManualResetEvent StopRequest = new ManualResetEvent(false);
public static int MessageService { get; private set; }
public static void Main()
{
LogInfo("Application started");
StartupConfigController.ReadStartupConfig();
DatabaseContext.TestDatabaseConnection();
// Start self host application
string configuredUri = "http://localhost:" + ServerConfig.ServerPort.ToString();
// Start WinForm
ServerControlWindow.Start();
// Register listener to "close application" messages
MessageServices.Current.Subscribe(STOP_SERVER, (a, b) =>
{
StopRequest.Set();
});
// Start Threads
ThreadsHandler.Start();
// Start listeners
ListenersHandler.Start();
// Start server services
using (WebApp.Start<Step.App_Start.Startup>(url: configuredUri))
{
// Wait interrupt from client
StopRequest.WaitOne();
// Stop Threads
ThreadsHandler.Stop();
// Stop messageservice listeners
ListenersHandler.Stop();
LogInfo("Application closed");
}
// Close WinForm
ServerControlWindow.Stop();
}
}
}