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