Files
Shi.Ji e31d3560bb 添加 MX-PD-盘古 项目文件
将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
2026-05-18 11:43:09 +08:00

54 lines
1.4 KiB
C#

using MainShell.Common;
using MaxwellFramework.Core.Attributes;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell
{
[Singleton]
public class MachineState : PropertyChangedBase
{
private readonly object _sync = new object();
private MachineMode _currentMode = MachineMode.Manual;
private bool _isExiting = false;
public MachineMode CurrentMode
{
get { lock (_sync) { return _currentMode; } }
set
{
bool changed;
lock (_sync)
{
changed = _currentMode != value;
_currentMode = value;
}
// 在锁外触发通知,避免死锁
if (changed)
NotifyOfPropertyChange(nameof(CurrentMode));
}
}
public bool IsExiting
{
get { lock (_sync) { return _isExiting; } }
set
{
bool changed;
lock (_sync)
{
changed = _isExiting != value;
_isExiting = value;
}
if (changed)
NotifyOfPropertyChange(nameof(IsExiting));
}
}
}
}