修改创建目录时机
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -514,6 +514,7 @@ namespace JoyD.Windows.CS.Toprie
|
||||
/// </summary>
|
||||
private void LoadAllConfigs()
|
||||
{
|
||||
Console.WriteLine($"正在加载配置:{ProjectPath}");
|
||||
LoadZoneConfig();
|
||||
LoadTemperatureDiffConfig();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user