Skip to content

Commit

Permalink
small fix to reader task disposing
Browse files Browse the repository at this point in the history
  • Loading branch information
genemars committed Aug 18, 2015
1 parent 09dac32 commit 0bbeeac
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions SerialPortLib/SerialPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ public void Disconnect()
{
watcherTokenSource.Cancel();
connectionWatcher.Wait(5000);
connectionWatcher.Dispose();
if (connectionWatcher != null)
connectionWatcher.Dispose();
connectionWatcher = null;
watcherTokenSource = null;
}
Expand Down Expand Up @@ -224,7 +225,8 @@ private void Close()
{
readerTokenSource.Cancel();
readerTask.Wait(5000);
readerTask.Dispose();
if (readerTask != null)
readerTask.Dispose();
readerTask = null;
readerTokenSource = null;
}
Expand Down

0 comments on commit 0bbeeac

Please sign in to comment.