From 7c6f50f85c0e0176354e7f9ce18658e8fd5698a7 Mon Sep 17 00:00:00 2001 From: LeiYangGH <675686066@qq.com> Date: Thu, 2 Mar 2017 22:26:47 +0800 Subject: [PATCH 1/2] set _rxThread to Background thread, making sure it will exit when the main(UI) thread exits --- PInvokeSerialPort/SerialPort.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PInvokeSerialPort/SerialPort.cs b/PInvokeSerialPort/SerialPort.cs index c9d1021..5d8a644 100755 --- a/PInvokeSerialPort/SerialPort.cs +++ b/PInvokeSerialPort/SerialPort.cs @@ -109,6 +109,8 @@ namespace PInvokeSerialPort Name = "CommBaseRx", Priority = ThreadPriority.AboveNormal }; + //If not set to true, my application process will not exit completely after UI closed + _rxThread.IsBackground = true; _rxThread.Start(); Thread.Sleep(1); //Give rx thread time to start. By documentation, 0 should work, but it does not! From da7a692a7b37cb7dd280ad14e64c83244c8617c2 Mon Sep 17 00:00:00 2001 From: LeiYangGH <675686066@qq.com> Date: Thu, 2 Mar 2017 22:53:26 +0800 Subject: [PATCH 2/2] merge commit 90ad497d35337dacbeb0bc6c284bd0b91df0cf6b --- PInvokeSerialPort/SerialPort.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PInvokeSerialPort/SerialPort.cs b/PInvokeSerialPort/SerialPort.cs index 5d8a644..f0b86c8 100755 --- a/PInvokeSerialPort/SerialPort.cs +++ b/PInvokeSerialPort/SerialPort.cs @@ -711,8 +711,8 @@ namespace PInvokeSerialPort get { return _handShake; } set { - Handshake = value; - switch (Handshake) + _handShake = value; + switch (_handShake) { case Handshake.None: TxFlowCts = false; TxFlowDsr = false; TxFlowX = false;