示例#1
0
        public void Dispose()
        {
            lock (disposedSync)
            {
                if (alreadyDisposed)
                {
                    return;
                }
                alreadyDisposed = true;
            }
            Pause();
            if (recorder != null)
            {
                recorder.Dispose();
            }
            if (player != null)
            {
                player.Dispose();
                LocalTimeSource.SyncHook -= player.Play;
            }

            // ordering below is due to the fact that the CPU can use other peripherals, e.g. Memory so it should be disposed last
            foreach (var peripheral in GetPeripheralsOfType <IDisposable>().OrderBy(x => x is ICPU ? 0 : 1))
            {
                this.DebugLog("Disposing {0}.", GetAnyNameOrTypeName((IPeripheral)peripheral));
                peripheral.Dispose();
            }
            LocalTimeSource.Dispose();
            this.Log(LogLevel.Info, "Disposed.");
            var disposed = StateChanged;

            if (disposed != null)
            {
                disposed(this, new MachineStateChangedEventArgs(MachineStateChangedEventArgs.State.Disposed));
            }

            EmulationManager.Instance.CurrentEmulation.BackendManager.HideAnalyzersFor(this);
        }