Skip to content

Commit

Permalink
Added trycatch on closing port. Added info when closing port
Browse files Browse the repository at this point in the history
  • Loading branch information
kpierzynski committed Jan 6, 2022
1 parent 579e159 commit d72e875
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion FlexSerial/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,16 @@ void baud_PreviewTextInput(object sender, TextCompositionEventArgs e)

private void pause_Click(object sender, RoutedEventArgs e)
{
serialPort.Close();
try
{
serialPort.Close();
info.Text = "Port closed successfully";
}
catch (Exception ex)
{
info.Text = ex.Message;
}

start.IsEnabled = !serialPort.IsOpen;
pause.IsEnabled = serialPort.IsOpen;
}
Expand Down

0 comments on commit d72e875

Please sign in to comment.