cancellation Questions
3
Solved
I have an async iterator method that produces an IAsyncEnumerable<int> (a stream of numbers), one number every 200 msec. The caller of this method consumes the stream, but wants to stop the e...
Phosphorite asked 4/10, 2019 at 10:39
2
I've been working on a feature that queues time consuming work in a channel, and there I iterate the channel using e.g.
await foreach(var item in channel.Reader.ReadAllAsync(cancellationToken)) {.....
Stelly asked 17/5, 2021 at 12:34
2
Solved
The problem (I think)
The contextlib.asynccontextmanager documentation gives this example:
@asynccontextmanager
async def get_connection():
conn = await acquire_db_connection()
try:
yield conn
...
Lamanna asked 2/8, 2021 at 15:32
2
Solved
I found beneath code for execute some process without freezing UI. This code is executed when 'Start Work' button is pressed. And I think users would stop this work by 'Stop' button. So I found thi...
Kriegspiel asked 10/12, 2015 at 10:36
2
Solved
I am currently implementing some services based on the design of the UserManger of Asp.Net Core Identity.
In the Implementation i wondered how the usermanager is possible to support cancellation i...
Iolanthe asked 8/11, 2019 at 9:8
1
Solved
I'm using an async api which supports cancellation and I'm passing to that api a CancellationToken instance. As usual, if the cancellation is requested on the passed token, the api that I'm invokin...
Tutuila asked 21/4, 2021 at 21:36
4
Solved
How can I cancel exiting from particular form after Cancel button (or X at the top right corner, or Esc) was clicked?
WPF:
<Window
...
x:Class="MyApp.MyView"
...
/>
<Button Content="...
Griffiths asked 21/3, 2016 at 11:5
3
Solved
I'm attempting to use Reactive Extensions (Rx) to process a stream of data. The processing of each element may take some time, though. To break the processing, I'm using a CancellationToken, which ...
Manutius asked 19/7, 2017 at 14:37
5
Solved
I have a very simple IObservable<int> that acts as a pulse generator every 500ms:
var pulses = Observable.GenerateWithTime(0, i => true, i => i + 1, i => i,
i => TimeSpan.FromMi...
Foretopgallant asked 20/7, 2011 at 9:36
1
Solved
For a while I've been trying to get my head around the whole async/await model that C# uses for asynchronous code. The addition of async streams (the IAsyncEnumerable<T> type) seemed really ...
Omaomaha asked 4/12, 2020 at 7:2
17
Solved
Is there a method for clearing the .thens of a JavaScript Promise instance?
I've written a JavaScript test framework on top of QUnit. The framework runs tests synchronously by running each one in a...
Vesper asked 6/4, 2015 at 20:3
3
Solved
I have wrapped a callback in suspendCancellableCoroutine to convert it to a suspend function:
suspend fun TextToSpeech.speakAndWait(text: String) : Boolean {
val uniqueUtteranceId = getUniqueUtter...
Charest asked 9/10, 2020 at 10:31
2
Solved
I want to add a cancel method to a subclass of the Promise built-in. Why does this not work?
class CancellablePromise extends Promise {
constructor(executor) {
let cancel = null
super((resol...
Cowbell asked 1/10, 2020 at 12:44
3
I'm porting some old RxJava code to Coroutines. With RxJava I could do this in my activity:
someBgOperation()
.as(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from(MyActivity.this)))
....
Cowey asked 5/6, 2020 at 16:43
4
Does anyone know how to use Android device's built-in acoustic echo cancellation? It is located somewhere in silicon and is used for GSM/CDMA speakerphone calls. We'd really like to tap into it for...
Natika asked 20/10, 2010 at 18:53
1
My application has the following top-level code (slightly abbreviated):
def main():
# Some setup code ...
try:
asyncio.run(my_coroutine())
except Exception as e:
print("Exiting due to excepti...
Aldarcy asked 11/2, 2020 at 11:20
6
Solved
I find myself writing code like this a lot:
try
{
cancellationTokenSource.Cancel();
await task.ConfigureAwait(false); // this is the task that was cancelled
}
catch(OperationCanceledException)
{
...
Declarer asked 20/12, 2019 at 18:29
1
Solved
Hi I have a listbox Whenever a user selects an item a request is sent to the web Now I want to cancel the previous operation when the user selected the item and then start the new operation.
I use...
Circumnavigate asked 26/12, 2019 at 5:59
2
Solved
Obviously I realize it enables me to cancel the task, but this code achieves the same effect without having to pass the token into Task.Run
What is the practical difference? Thanks.
Dim cts As Ne...
Lanlana asked 18/1, 2018 at 1:33
1
Maybe the answer is obvious for many, but I am quite surprised I could not find a question regarding this topic, which represents a major problem for me.
I would greatly appreciate a hint!
When su...
Filiate asked 25/9, 2018 at 14:33
1
Solved
I've read Stephen Toub's blog about making a custom awaitable for SocketAsyncEventArgs. This works all fine. But what I need is a cancellable awaitable and the blog doesn't cover this topic. Also S...
Fibroma asked 6/12, 2019 at 9:9
4
I have a legacy scenario where a ref bool was being used to send a cancellation signal to an implementation. Now, I want to call a Task-based library method that takes a CancellationToken instance,...
Devitrify asked 1/11, 2019 at 14:57
0
Suppose we have a trivial "cancel with timout" case (Kotlin 1.3.50, kotlinx-coroutines-core 1.3.2):
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.delay
import kotlinx.coroutines...
Hebetic asked 21/10, 2019 at 8:22
3
Solved
Background:
I have a web application which kicks off long running (and stateless) tasks:
var task = Task.Run(() => await DoWork(foo))
task.Wait();
Because they are long running, I need to b...
Brune asked 23/7, 2019 at 20:48
5
Solved
What's the best way to sleep a certain amount of time, but be able to be interrupted by a IsCancellationRequested from a CancellationToken?
I'm looking for a solution which works in .NET Framework ...
Chanty asked 10/9, 2013 at 9:21
© 2022 - 2024 — McMap. All rights reserved.