private void SetRunState(RunState state) { if (m_State == RunState.Stopped && state == RunState.Stopped) { return; } m_State = state; if (state == RunState.Paused) { if (m_Debugger != null) { m_Debugger.Report(); } } // Start point of the Machine boot process if (m_State == RunState.Running && !m_Booted) { // First tell the machine to initilize subcomponents InitializeComponents(); // Tell the machine to load in media resources (disk, etc) if (!Resources.LoadResources()) { m_Booted = false; m_State = RunState.Stopped; throw new VMException("Resources failed to load!"); } // Tell the machine to finally run the machine if (!Boot()) { m_Booted = false; m_State = RunState.Stopped; throw new VMException("Machine has failed to boot!"); } else { m_Booted = true; Console.WriteLine("Machine has booted successfully!"); if (m_Debugger != null) { m_Debugger.StartDebugging(this); m_Debugger.Report(); } } } if (m_State == RunState.Stopped) { m_Booted = false; if (m_Debugger != null) { m_Debugger.StopDebugging(); } } if (RunningStateChanged != null) { RunningStateChanged(this, new RunStateChangedArgs(m_State)); } OnStateChanged(m_State); }