mirror of
https://github.com/DarthAffe/OBD.NET.git
synced 2026-11-11 21:16:25 +00:00
This commit is contained in:
1 parent
d2c2b8456f
commit
6728f6413d
1 file changed
+6
@@ -222,6 +222,8 @@ namespace OBD.NET.Devices
|
|||||||
while (!commandCancellationToken.IsCancellationRequested)
|
while (!commandCancellationToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
currentCommand = null;
|
currentCommand = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
if (commandQueue.TryTake(out currentCommand, Timeout.Infinite, commandCancellationToken.Token))
|
if (commandQueue.TryTake(out currentCommand, Timeout.Infinite, commandCancellationToken.Token))
|
||||||
{
|
{
|
||||||
Logger?.WriteLine("Writing Command: '" + currentCommand.CommandText.Replace('\r', '\'') + "'", OBDLogLevel.Verbose);
|
Logger?.WriteLine("Writing Command: '" + currentCommand.CommandText.Replace('\r', '\'') + "'", OBDLogLevel.Verbose);
|
||||||
@@ -239,6 +241,9 @@ namespace OBD.NET.Devices
|
|||||||
commandFinishedEvent.WaitOne();
|
commandFinishedEvent.WaitOne();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (OperationCanceledException)
|
||||||
|
{/*ignore, because it is thrown when the cancellation token is canceled*/}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -246,6 +251,7 @@ namespace OBD.NET.Devices
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Dispose()
|
public virtual void Dispose()
|
||||||
{
|
{
|
||||||
|
commandQueue.CompleteAdding();
|
||||||
commandCancellationToken?.Cancel();
|
commandCancellationToken?.Cancel();
|
||||||
commandWorkerTask?.Wait();
|
commandWorkerTask?.Wait();
|
||||||
Connection?.Dispose();
|
Connection?.Dispose();
|
||||||
|
|||||||
Reference in new issue
Block a user