public SystemManager() { Instance = this; MCP.IAS = 120; MCP.ALT = 1200; MCP.VS = 0; FlightPlan.LoadFromFile(@"c:\workspace\FlightPlan.txt"); Computer = new FlightDataComputer(MCP, App.Controller); Nav = new FlightNavigator(MCP, FlightPlan); IndicatorHost = new IndicatorHandler(Computer); Timeline.Begin(); if (App.IsRunning) { App.FrameProduced += OnFrameProduced; App.Controller.ButtonPressed += Controler_ButtonPressed; App.Controller.ControllerInput += Controller_ControllerInput; App.PropertyChanged += XboxApp_PropertyChanged; App.Begin(); Nav.Begin(); } else { Replay = new ReplayFrameProducer(@"C:\save\recording3"); Replay.FrameProduced += OnFrameProduced; Replay.Begin(); } }
public IndicatorHandler(FlightDataComputer computer) { _computer = computer; new Thread(() => { StartWorkerThread(); // This delay exists because there seems to be a race condition in initializing EmguCV // when multiple threads go at it we see AccessViolationExceptions, mostly out of Blob detection. Thread.Sleep(1000); StartWorkerThread(); StartWorkerThread(); StartWorkerThread(); StartWorkerThread(); StartWorkerThread(); StartWorkerThread(); }).Start(); }