void SyncState(Serializer ser) { byte[] core = null; if (ser.IsWriter) { var ms = new MemoryStream(); theMachine.Serialize(new BinaryWriter(ms)); ms.Close(); core = ms.ToArray(); } ser.BeginSection("Atari7800"); ser.Sync("core", ref core, false); ser.Sync("Lag", ref _lagcount); ser.Sync("Frame", ref _frame); ser.Sync("IsLag", ref _islag); ser.EndSection(); if (ser.IsReader) { theMachine = MachineBase.Deserialize(new BinaryReader(new MemoryStream(core, false))); avProvider.ConnectToMachine(theMachine, GameInfo); } }