|
@@ -101,41 +101,54 @@ namespace ST_LINK_MES
|
|
|
uxBinFilePath.Text = dlg.FileName;
|
|
|
}
|
|
|
|
|
|
- private void uxRunBtn_Click(object sender, RoutedEventArgs e)
|
|
|
+ private async void uxRunBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- uxTerminal.Document.Blocks.Clear();
|
|
|
-
|
|
|
- if (string.IsNullOrEmpty(uxSN.Text))
|
|
|
+ uxRunBtn.IsEnabled = false;
|
|
|
+ try
|
|
|
{
|
|
|
- AddTerminalMsg("ERROR: SN Should not be empty");
|
|
|
- return;
|
|
|
- }
|
|
|
+ uxTerminal.Document.Blocks.Clear();
|
|
|
|
|
|
- if (!ValidateSN())
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (string.IsNullOrEmpty(uxSN.Text))
|
|
|
+ {
|
|
|
+ AddTerminalMsg("ERROR: SN Should not be empty");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- string filePath = uxBinFilePath.Text;
|
|
|
- if (!File.Exists(filePath))
|
|
|
- {
|
|
|
- AddTerminalMsg("ERROR: Program file not found");
|
|
|
- return;
|
|
|
- }
|
|
|
+ if (!ValidateSN())
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- string cliPath = stlinkService.CliPath;
|
|
|
- if (!File.Exists(filePath))
|
|
|
+ string filePath = uxBinFilePath.Text;
|
|
|
+ if (!File.Exists(filePath))
|
|
|
+ {
|
|
|
+ AddTerminalMsg("ERROR: Program file not found");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ string cliPath = stlinkService.CliPath;
|
|
|
+ if (!File.Exists(filePath))
|
|
|
+ {
|
|
|
+ AddTerminalMsg("ERROR: ST-LINK_CLI not found");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ fileRrecordService.Start(uxSN.Text);
|
|
|
+ var task = new Task(() =>
|
|
|
+ {
|
|
|
+ StartProgram(filePath);
|
|
|
+ });
|
|
|
+ await task;
|
|
|
+ //task.Start();
|
|
|
+ }
|
|
|
+ catch (Exception error)
|
|
|
{
|
|
|
- AddTerminalMsg("ERROR: ST-LINK_CLI not found");
|
|
|
- return;
|
|
|
+ MessageBox.Show(error.Message);
|
|
|
}
|
|
|
-
|
|
|
- fileRrecordService.Start(uxSN.Text);
|
|
|
- var task = new Task(() =>
|
|
|
+ finally
|
|
|
{
|
|
|
- StartProgram(filePath);
|
|
|
- });
|
|
|
- task.Start();
|
|
|
+ uxRunBtn.IsEnabled = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void StartProgram(string filePath)
|