-
Notifications
You must be signed in to change notification settings - Fork 805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MailboxProcessor.PostAndAsyncReply doesn't handle CancellationToken properly #4448
Comments
@stmax82 Hmmm... in your example did you mean to add an explicit cancellation of the |
OK, added
and this repros |
BTW a semi-workaround is to specify a timeout of Int32.MaxValue. I actually thought we had fixed this though, it might be another case of the same problem
|
@dsyme This reminds me to
However, without looking at the code, I'd assume that it has to do something with the async |
@dsyme no need for cancel.Cancel() nor "use" - in my example the CancellationTokenSource has a timeout of 3 seconds, see: use cancel = new CancellationTokenSource(**3000**) .. so it automatically cancels the asyncs after 3 secs while the program is waiting in Console.ReadLine. You can as well use an explicit cancel.Cancel().. though you should add a short delay between Async.Start and cancel.Cancel() because otherwise it might happen that the asyncs get cancelled before execution enters the try-blocks - in which case they would get cancelled without printing the "good / bad async exited" messages. Thanks for looking into these problems. |
MailboxProcessor.PostAndAsyncReply can get stuck forever when the parent gets cancelled.
The following starts two asyncs in parallel and then cancels their parent.
One of the asyncs exits by printing "good async exited", while the other one gets stuck in PostAndAsyncReply forever (it never prints "bad async exited").
Tested with VS 2017 15.5.7 and net461 and netcoreapp2.0.. though the behaviour is the same since at least 2014.
With the MailboxProcessor and PostAndAsyncReply being such basic functionality, I think this should be cancelable. Tomas Petricek once wrote:
The text was updated successfully, but these errors were encountered: