/// <summary> /// The application worker thread. /// </summary> private void AppThread() { // All NeonSwitch applications (except for the core service) need to wait for // the core to be initialized before the application can be started. We're // going to spin here until the core indicates that it's ready. var warningTimer = new PolledTimer(TimeSpan.FromSeconds(60)); if (!SwitchApp.IsCore) { while (true) { if (String.Compare(Switch.GetGlobal(SwitchGlobal.NeonSwitchReady), "true", true) == 0) { break; } if (warningTimer.HasFired) { warningTimer.Disable(); SysLog.LogWarning("NeonSwitch application [{0}] has waited [{1}] for the core NeonSwitch service to start.", SwitchApp.Name, warningTimer.Interval); } Thread.Sleep(TimeSpan.FromSeconds(1)); } } // Continue performing wwitch initialization. We needed to wait until after // the NeonSwitch core service started before calling this. Switch.Initialize(); // Call the application entry point so it can initalize itself. try { InMain = true; Main(); InMain = false; mainCalled = true; } catch (Exception e) { SysLog.LogException(e, "The NeonSwitch application's Main() method threw an exception."); throw; } finally { InMain = false; } // NeonSwitch handles the event dispatching. Switch.EventLoop(); }