Open Vlad-00003 opened 1 year ago
The only solution I found so far is to manually cancel token on ProcessExited event & use solution from here: https://github.com/Azure/azure-storage-net/issues/765
But surly enough it throws TaskCanceledException
Hmm, I do remember code outside the while loop never running, I think you could just add a try catch for the TaskCancelledException
around the while loop and just go from there.
The pty connection was never the best but it's the only option you have with steamcmd as they didn't properly flush the stdout/stderr streams, pty allows us to flush the stream from the consuming side but is a bit temperamental.
I would probably make SteamCmdCommand disposable now too so that you can properly clear up resources.
It is strange that setting the task result doesn't bomb out of the while loop but it's probably holding the thread because work has started (it tried to read) and hasn't been cancelled
You could try making it synchronous so that the read never starts after the process has exited and only have the while check if read > 0
You could also try calling DisposeAsync
on the ReaderStream
and WriterStream
when the process is exiting.
Yeah, that's exactly what I did - catching TaskCancelledException
and just letting it go
The thing is - while ReadAsync takes CancellationToken it doesn't look like it actually uses it after BeginEndReadAsync call but yeah - at the end of the day I ended up manually canceling token and disposing the connection
I was mostly wondering if you ran into the same issue as well
Hello!
Sorry but it's me again 😅 For some reason ExecuteAsync in SteamCmdCommand never actually stops. (I also can't use debugger on this project, but that's besides the point)
From what I managed to gather: connection.ProcessExited does getting called and _process.TrySetResult seems to be working yet for some weird reason after steam "says it's last words" the thread just keeps waiting
Another weird thing - as soon as I attach debugger, adding a slight delay into the while loop - everything works just fine. On my own test code (exactly the same code but I can use the debugger there) I managed to notice this:
And I don't know if there is something wrong with my conpty.dll but still - as soon as I add a breakpoint to the output - it's working.
I have a feeling that for some reason token doesn't work yet have no idea why and if you did encounter such behavior