/// <summary> /// Respond to the state changes of the Spectrum virtual machine /// </summary> /// <remarks> /// This method is called from a background thread! /// </remarks> private void OnVmStateChanged(VmStateChangedMessage message) { Dispatcher.Invoke(() => { switch (message.NewState) { case VmState.Stopped: _dispatchTimer.Stop(); Vm.EarBitFrameProvider.KillSound(); Vm.SpectrumVm.TapeDevice.FastLoadCompleted -= OnFastLoadCompleted; break; case VmState.Running: _dispatchTimer.Stop(); Vm.EarBitFrameProvider.PlaySound(); Vm.SpectrumVm.TapeDevice.FastLoadCompleted += OnFastLoadCompleted; break; case VmState.Paused: Vm.EarBitFrameProvider.PauseSound(); _dispatchTimer.Start(); break; } }, DispatcherPriority.Send); }
/// <summary> /// Dispatch the vm state changed message on the UI thread /// </summary> /// <param name="msg">Message received</param> private void OnInternalVmStateChanged(VmStateChangedMessage msg) { DispatchOnUiThread(() => OnVmStateChanged(msg.OldState, msg.NewState)); }
/// <summary> /// Changes the caption whenever the VM state changes /// </summary> /// <param name="msg"></param> protected virtual void OnVmStateChanged(VmStateChangedMessage msg) { ChangeCaption(msg.NewState); }