Skip to content
This repository was archived by the owner on Sep 7, 2023. It is now read-only.

Commit a2b8b80

Browse files
committed
fix: fix crashing when interrupted
1 parent c6a6b85 commit a2b8b80

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Source/MainWindow.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,14 @@ private void Communicate()
463463
opponentChargingPiles: opponentChargingPiles
464464
);
465465
var bytesToWrite = gameInfoPacket.GetBytes();
466-
467-
this._serialPortDict[camp].Write(bytesToWrite, 0, bytesToWrite.Length);
466+
try
467+
{
468+
this._serialPortDict[camp].Write(bytesToWrite, 0, bytesToWrite.Length);
469+
}
470+
catch (Exception)
471+
{
472+
// Empty
473+
}
468474
isMessageSent = true;
469475
}
470476
else if (packetFromSlave.GetPacketId() == PacketSetChargingPileSlave.PacketId)
@@ -538,7 +544,15 @@ private void Communicate()
538544

539545
var bytesToWrite = packet.GetBytes();
540546

541-
this._serialPortDict[camp].Write(bytesToWrite, 0, bytesToWrite.Length);
547+
try
548+
{
549+
this._serialPortDict[camp].Write(bytesToWrite, 0, bytesToWrite.Length);
550+
}
551+
catch (Exception)
552+
{
553+
// Empty
554+
}
555+
542556
isMessageSent = true;
543557
}
544558
}

0 commit comments

Comments
 (0)