修改创建目录时机

This commit is contained in:
zqm
2026-01-13 13:57:43 +08:00
parent b2214998f2
commit 4a01611ade
2 changed files with 20 additions and 13 deletions

View File

@@ -367,8 +367,6 @@ namespace JoyD.Windows.CS.Toprie
// 配置文件存储在Config子目录中
string configDir = Path.Combine(_projectPath, "Config");
// 确保Config目录存在
Directory.CreateDirectory(configDir);
string configPath = Path.Combine(configDir, "测温区信息.csv");
if (!File.Exists(configPath))
@@ -435,8 +433,6 @@ namespace JoyD.Windows.CS.Toprie
// 配置文件存储在Config子目录中
string configDir = Path.Combine(_projectPath, "Config");
// 确保Config目录存在
Directory.CreateDirectory(configDir);
string configPath = Path.Combine(configDir, "温差数据.csv");
if (!File.Exists(configPath))
@@ -793,6 +789,7 @@ namespace JoyD.Windows.CS.Toprie
{
try
{
Console.WriteLine("正在加载并启动相机");
// 启动设备Ping
StartDevicePing();
// 延迟启动相机,避免界面卡顿
@@ -801,17 +798,26 @@ namespace JoyD.Windows.CS.Toprie
while (!IsDevicePingable)
Thread.Sleep(3000); // 延迟3秒后启动
_isFirst = false;
this.Invoke(new Action(() =>
// 确保窗口句柄已经创建避免Invoke时抛出异常
while (!this.IsHandleCreated)
Thread.Sleep(100); // 等待窗口句柄创建
// 使用Invoke或BeginInvoke调用UI线程操作
if (this.IsHandleCreated)
{
try
this.BeginInvoke(new Action(() =>
{
StartCamera();
}
catch (Exception ex)
{
ShowError($"自动启动相机失败: {ex.Message}");
}
}));
try
{
StartCamera();
}
catch (Exception ex)
{
ShowError($"自动启动相机失败: {ex.Message}");
}
}));
}
});
}
catch (Exception ex)

View File

@@ -514,6 +514,7 @@ namespace JoyD.Windows.CS.Toprie
/// </summary>
private void LoadAllConfigs()
{
Console.WriteLine($"正在加载配置:{ProjectPath}");
LoadZoneConfig();
LoadTemperatureDiffConfig();
}