Skip to content

Commit

Permalink
Fix for: reading data too early, null reference
Browse files Browse the repository at this point in the history
  • Loading branch information
1-max-1 committed Nov 24, 2024
1 parent 43b4835 commit 8c85f3a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions WASMSerialTerminal/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
private const int MAX_BYTES = 150000;

protected override void OnInitialized() {
serialService.DataReceived += OnSerialDataReceived;
serialService.SerialError += OnSerialError;
}

Expand All @@ -91,6 +90,7 @@

serialDataStream = new();
dataStreamReader = new(serialDataStream, textEncoding, false, -1, true);
serialService.DataReceived += OnSerialDataReceived;
}
}
catch (SerialSecurityException) {
Expand All @@ -107,8 +107,9 @@
connectionStatusText = "(Disconnected)";
connectionStatusBoldText = "";

serialDataStream!.Close();
dataStreamReader!.Close();
serialService.DataReceived -= OnSerialDataReceived;
serialDataStream?.Close();
dataStreamReader?.Close();
}

private async Task OnDisconnectButtonClick() {
Expand Down

0 comments on commit 8c85f3a

Please sign in to comment.