1
0
mirror of https://github.com/DarthAffe/OBD.NET.git synced 2025-12-12 16:58:30 +00:00
Roman Lumetsberger 2017-08-18 16:04:51 +02:00
parent d2c2b8456f
commit 6728f6413d

View File

@ -222,6 +222,8 @@ namespace OBD.NET.Devices
while (!commandCancellationToken.IsCancellationRequested)
{
currentCommand = null;
try
{
if (commandQueue.TryTake(out currentCommand, Timeout.Infinite, commandCancellationToken.Token))
{
Logger?.WriteLine("Writing Command: '" + currentCommand.CommandText.Replace('\r', '\'') + "'", OBDLogLevel.Verbose);
@ -239,6 +241,9 @@ namespace OBD.NET.Devices
commandFinishedEvent.WaitOne();
}
}
catch (OperationCanceledException)
{/*ignore, because it is thrown when the cancellation token is canceled*/}
}
}
/// <summary>
@ -246,6 +251,7 @@ namespace OBD.NET.Devices
/// </summary>
public virtual void Dispose()
{
commandQueue.CompleteAdding();
commandCancellationToken?.Cancel();
commandWorkerTask?.Wait();
Connection?.Dispose();