We were sometimes seeing the Plc connection being closed when cancelling a WriteBytesAsync/ReadBytesAsync which then lead to random ObjectDisposedExceptions as in #528
I traced this back to this line in NoLockRequestTsduAsync:
using var closeOnCancellation = cancellationToken.Register(Close);
I guess this is because the WriteAsync/ReadAsync query-response pair in NoLockRequestTsduAsync cannot easily be split, but I still found this behavior surprising. Right now, our workaround is not to pass in the CancellationToken at all and just hope that each query is fast enough. Is there a better way of handling this? Maybe only cancelling the task that the user is waiting on but not the query itself once it is running?
We were sometimes seeing the
Plcconnection being closed when cancelling aWriteBytesAsync/ReadBytesAsyncwhich then lead to randomObjectDisposedExceptionsas in #528I traced this back to this line in
NoLockRequestTsduAsync:using var closeOnCancellation = cancellationToken.Register(Close);I guess this is because the
WriteAsync/ReadAsyncquery-response pair inNoLockRequestTsduAsynccannot easily be split, but I still found this behavior surprising. Right now, our workaround is not to pass in theCancellationTokenat all and just hope that each query is fast enough. Is there a better way of handling this? Maybe only cancelling the task that the user is waiting on but not the query itself once it is running?