750 questions
0
votes
1
answer
111
views
How to terminate an asynchronous function at any point?
I'm looking to cancel an asynchronous function based on a signal that can be controlled by anything, similar to how a fetch can be aborted through the use of an AbortController - effectively ...
0
votes
3
answers
145
views
Are there any real difference between GlobalScope and CoroutineScope?
I'm trying to understand the difference between the 2.
If a CoroutineScope is not tied to any lifecycle-aware component, then I think they behave the same:
If Im not passing any context to ...
1
vote
0
answers
94
views
How to cancel a gRPC client streaming call cleanly without triggering RpcException, ObjectDisposedException, or InvalidOperationException?
I'm working on a gRPC client that continuously streams data (such as images) from a server. I use a CancellationToken to stop the stream when needed. While cancellation works, I consistently see ...
1
vote
0
answers
98
views
Cleanup after waiting for first asyncio task to complete: Is it safe to swallow CancelledError when raised by task.get_exception()?
I have an asyncio function that spawns multiple tasks, any of which can return a result, in which case we want to shut down all the others.
Right now, it does so in a matter something like the ...
0
votes
1
answer
180
views
What is the significance of the cancellation token in the call to Task.Run? [duplicate]
In my application I have a synchronous method that I am calling asynchronously by invoking Task.Run. I've noticed that the Task.Run call takes a cancellation token. However, in my tests I noticed that ...
3
votes
2
answers
205
views
How to detect stdin input in a cancel-safe way in Rust async?
Problem
I'm working with asynchronous code in Rust and trying to handle user input from stdin in a cancel-safe manner. My goal is to be able to detect when a user presses a key (or hits enter) to ...
1
vote
1
answer
76
views
Design pattern with multiple cancellable tasks and unhandled exception handling [duplicate]
I want a C# console app that
Runs multiple tasks
Cancellable by Control C
Unhandled exceptions in one task, cleanly cancel the other tasks.
The below code deals with the cancellation correctly, but ...
3
votes
2
answers
128
views
Is there an event I can subscribe to from a job that is raised when Stop-Job is invoked on that job?
The following code demonstrates that a long-running (but, in principle, cancellable) .Net method called from a job runs to completion even when the job is stopped:
$stopwatch = [System.Diagnostics....
0
votes
0
answers
107
views
Handling TaskCanceledException by IExceptionHandler
I'm trying to implement a generic timeout for my requests in C#. I'm aware of the request timeout middleware, but it can't be instructed (as the middleware is handling the exception) to pass the ...
0
votes
1
answer
87
views
.NET 8 socket ReadAsync: why the last reply is reported exactly at the time of cancellation?
I need to wait for replies for UDP broadcast with timeout, so I try ReadAsync with cancellation token and Threading.Timer to signal cancellation. There are two other computers, which reply to the ...
1
vote
1
answer
105
views
Merging two IAsyncEnumerable instances with cancellation support (NotSupportedException)
I'm having trouble implementing the following properly:
I have two IAsyncEnumerable instances (of the same type), one is the "primary" source, the purpose of the other is so the user can &...
0
votes
1
answer
619
views
How to prevent <dialog> to close with Esc key [duplicate]
The HTML element <dialog> is intended to always be closed when you press Esc key according to documentation. The problem with that is that you might want it not to close immediately, i.e. if you ...
2
votes
1
answer
126
views
Unable to cancel a Task returned by TaskCompletionSource by injecting a timeout in C#
I have the following method that waits for an event to happen to set the results by a TaskCompletionSource.
private async Task<string?> RequestDataAsync(string? remoteEntity, CancellationToken ...
-1
votes
1
answer
77
views
Cancelling an upload request (using xhr, axios or superagent) blocks other following requests
My need is to upload a large file (several megabytes or even at least one gigabyte) and allow users to cancel the current upload request.
Unfortunately, when i cancel the request via AbortController, ...
0
votes
0
answers
77
views
How do I cancel a long running task from a DELETE endpoint in ASP.NET Core?
I have an API to generate a long running task and a different API to fetch the result (can also be called to get a partial result).
An example:
[HttpGet]
public IActionResult LongRunning()
{
var ...