fix for unhandled exception on com port disconnect

This commit is contained in:
Edward Wright 2019-09-15 20:36:47 -04:00
parent 3d8d02b572
commit 8c92e7092f
3 changed files with 13 additions and 6 deletions

View File

@ -15,10 +15,10 @@
<ROW Property="ARPURLINFOABOUT" Value="https://github.com/fasteddy516/SimplySerial"/> <ROW Property="ARPURLINFOABOUT" Value="https://github.com/fasteddy516/SimplySerial"/>
<ROW Property="ARPURLUPDATEINFO" Value="https://github.com/fasteddy516/SimplySerial/releases"/> <ROW Property="ARPURLUPDATEINFO" Value="https://github.com/fasteddy516/SimplySerial/releases"/>
<ROW Property="Manufacturer" Value="fasteddy516"/> <ROW Property="Manufacturer" Value="fasteddy516"/>
<ROW Property="ProductCode" Value="1033:{0971E5B3-8699-455B-A021-F2E589F2593A} " Type="16"/> <ROW Property="ProductCode" Value="1033:{4B5304F2-D8B2-474A-B1ED-E17F5F4BAFDC} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/> <ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="SimplySerial"/> <ROW Property="ProductName" Value="SimplySerial"/>
<ROW Property="ProductVersion" Value="0.4.0" Type="32"/> <ROW Property="ProductVersion" Value="0.4.1" Type="32"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/> <ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
<ROW Property="UpgradeCode" Value="{6A3965D3-95B6-4145-8B3C-6F55E2A16C31}"/> <ROW Property="UpgradeCode" Value="{6A3965D3-95B6-4145-8B3C-6F55E2A16C31}"/>
<ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/> <ROW Property="WindowsType9X" MultiBuildValue="DefaultBuild:Windows 9x/ME" ValueLocId="-"/>

View File

@ -15,10 +15,10 @@
<ROW Property="ARPURLINFOABOUT" Value="https://github.com/fasteddy516/SimplySerial"/> <ROW Property="ARPURLINFOABOUT" Value="https://github.com/fasteddy516/SimplySerial"/>
<ROW Property="ARPURLUPDATEINFO" Value="https://github.com/fasteddy516/SimplySerial/releases"/> <ROW Property="ARPURLUPDATEINFO" Value="https://github.com/fasteddy516/SimplySerial/releases"/>
<ROW Property="Manufacturer" Value="fasteddy516"/> <ROW Property="Manufacturer" Value="fasteddy516"/>
<ROW Property="ProductCode" Value="1033:{56D40C37-34BE-428A-99BB-93FC3F462DA5} " Type="16"/> <ROW Property="ProductCode" Value="1033:{97370BF7-42F7-4188-8407-28AC3032F7D6} " Type="16"/>
<ROW Property="ProductLanguage" Value="1033"/> <ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="SimplySerial"/> <ROW Property="ProductName" Value="SimplySerial"/>
<ROW Property="ProductVersion" Value="0.4.0" Type="32"/> <ROW Property="ProductVersion" Value="0.4.1" Type="32"/>
<ROW Property="REBOOT" MultiBuildValue="DefaultBuild:ReallySuppress"/> <ROW Property="REBOOT" MultiBuildValue="DefaultBuild:ReallySuppress"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/> <ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
<ROW Property="UpgradeCode" Value="{64061592-EDD5-474E-B846-4CA070788BBE}"/> <ROW Property="UpgradeCode" Value="{64061592-EDD5-474E-B846-4CA070788BBE}"/>

View File

@ -10,7 +10,7 @@ namespace SimplySerial
{ {
class SimplySerial class SimplySerial
{ {
static readonly string version = "0.4.0"; static readonly string version = "0.4.1";
static List<ComPort> availablePorts; static List<ComPort> availablePorts;
static SerialPort serialPort; static SerialPort serialPort;
@ -208,7 +208,14 @@ namespace SimplySerial
ExitProgram((e.GetType() + " occurred while attempting to read/write to/from " + port.name + "."), exitCode: -1); ExitProgram((e.GetType() + " occurred while attempting to read/write to/from " + port.name + "."), exitCode: -1);
else else
Output("\n<<< Communications Interrupted >>>\n"); Output("\n<<< Communications Interrupted >>>\n");
serialPort.Dispose(); try
{
serialPort.Dispose();
}
catch (Exception ex)
{
//nothing to do here, other than prevent execution from stopping if dispose() throws an exception
}
Thread.Sleep(2000); // sort-of arbitrary delay - should be long enough to read the "interrupted" message Thread.Sleep(2000); // sort-of arbitrary delay - should be long enough to read the "interrupted" message
Console.Clear(); Console.Clear();
if (autoConnect == AutoConnect.ANY) if (autoConnect == AutoConnect.ANY)