P0: GlobalInfo 四个 Dictionary 改为 ConcurrentDictionary
This commit is contained in:
@@ -227,7 +227,7 @@ namespace ACP.ViewModels
|
|||||||
SettingChannelCommand = new AsyncDelegateCommand(SilenceBuzzer);
|
SettingChannelCommand = new AsyncDelegateCommand(SilenceBuzzer);
|
||||||
SettingChannelCommand = new DelegateCommand(SettingChannel);
|
SettingChannelCommand = new DelegateCommand(SettingChannel);
|
||||||
GoBackCommand = new DelegateCommand(OnGoBack);
|
GoBackCommand = new DelegateCommand(OnGoBack);
|
||||||
_globalInfo.ContextDic.Add("default", new ScopedContext());
|
_globalInfo.ContextDic.TryAdd("default", new ScopedContext());
|
||||||
|
|
||||||
_eventAggregator.GetEvent<LoginSuccessEvent>().Subscribe(() =>
|
_eventAggregator.GetEvent<LoginSuccessEvent>().Subscribe(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -217,10 +217,10 @@ namespace MainModule.ViewModels
|
|||||||
(LogAreaVM as IDisposable)?.Dispose();
|
(LogAreaVM as IDisposable)?.Dispose();
|
||||||
(ParametersManagerVM as IDisposable)?.Dispose();
|
(ParametersManagerVM as IDisposable)?.Dispose();
|
||||||
|
|
||||||
_globalInfo.ContextDic?.Remove(TestStatus);
|
_globalInfo.ContextDic?.TryRemove(TestStatus, out _);
|
||||||
_globalInfo.StepRunningDic?.Remove(TestStatus);
|
_globalInfo.StepRunningDic?.TryRemove(TestStatus, out _);
|
||||||
_globalInfo.ConfigDic?.Remove(TestStatus);
|
_globalInfo.ConfigDic?.TryRemove(TestStatus, out _);
|
||||||
_globalInfo.ScopeDic?.Remove(TestStatus);
|
_globalInfo.ScopeDic?.TryRemove(TestStatus, out _);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -275,10 +275,10 @@ namespace MainModule.ViewModels
|
|||||||
if (navigationContext.Parameters.ContainsKey("Name"))
|
if (navigationContext.Parameters.ContainsKey("Name"))
|
||||||
{
|
{
|
||||||
TestStatus = navigationContext.Parameters.GetValue<string>("Name");
|
TestStatus = navigationContext.Parameters.GetValue<string>("Name");
|
||||||
_globalInfo.ContextDic.Add(TestStatus, _scopedContext);
|
_globalInfo.ContextDic.TryAdd(TestStatus, _scopedContext);
|
||||||
_globalInfo.StepRunningDic.Add(TestStatus, _stepRunning);
|
_globalInfo.StepRunningDic.TryAdd(TestStatus, _stepRunning);
|
||||||
_globalInfo.ScopeDic.Add(TestStatus, _scope);
|
_globalInfo.ScopeDic.TryAdd(TestStatus, _scope);
|
||||||
_globalInfo.ConfigDic.Add(TestStatus, _systemConfig);
|
_globalInfo.ConfigDic.TryAdd(TestStatus, _systemConfig);
|
||||||
if(_systemConfig.DefaultProgramFilePath != null&&File.Exists(_systemConfig.DefaultProgramFilePath))
|
if(_systemConfig.DefaultProgramFilePath != null&&File.Exists(_systemConfig.DefaultProgramFilePath))
|
||||||
{
|
{
|
||||||
var filePath = _systemConfig.DefaultProgramFilePath;
|
var filePath = _systemConfig.DefaultProgramFilePath;
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ namespace UIShare.GlobalVariable
|
|||||||
public class GlobalInfo:BindableBase
|
public class GlobalInfo:BindableBase
|
||||||
{
|
{
|
||||||
public event EventHandler? ScopeChanged;
|
public event EventHandler? ScopeChanged;
|
||||||
public Dictionary<string,ScopedContext> ContextDic { get; set; }
|
public ConcurrentDictionary<string,ScopedContext> ContextDic { get; set; }
|
||||||
public Dictionary<string,StepRunning> StepRunningDic { get; set; }
|
public ConcurrentDictionary<string,StepRunning> StepRunningDic { get; set; }
|
||||||
public Dictionary<string, SystemConfig> ConfigDic { get; set; }
|
public ConcurrentDictionary<string, SystemConfig> ConfigDic { get; set; }
|
||||||
public Dictionary<string, IScopedProvider> ScopeDic { get; set; }
|
public ConcurrentDictionary<string, IScopedProvider> ScopeDic { get; set; }
|
||||||
|
|
||||||
/// <summary>硬件指纹 → 设备实例的并发池,确保同一物理硬件全局只创建一个驱动实例。</summary>
|
/// <summary>硬件指纹 → 设备实例的并发池,确保同一物理硬件全局只创建一个驱动实例。</summary>
|
||||||
public ConcurrentDictionary<string, Lazy<IBaseInterface>> HardwarePool { get; set; }
|
public ConcurrentDictionary<string, Lazy<IBaseInterface>> HardwarePool { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user