Questions tagged [taskcompletionsource]

TaskCompletionSource produces a Task unbound to a delegate, providing access to the consumer side through the Task property.

TaskCompletionSource produces a Task unbound to a delegate, providing access to the consumer side through the Task property.

References

79 questions
1
vote
2 answers

Waiting for events asynchronously in C#

I'm working on a WCF service/client trying to figure out how to replace a ManualResetEvent with something that won't block the caller thread. Most important is that await client.CloseAsync() won't be called until the FinishedEventReceived event has…
1
vote
1 answer

SignalR workaround to get client data from server

I know that SignalR can't have a return from client when invokation came from the server. On the github repository of SignalR I asked for a workaround (https://github.com/aspnet/SignalR/issues/1329) and they suggest me to get the result by sending…
1
vote
1 answer

Amazon IAP Plugin for Xamarin - crash when using TaskCompletionSource

I'm trying to implement a wrapper for the Amazon IAP Plugin for Xamarin. It uses an event based system in the following way: You can initiate method calls and listen for events. Method calls initiate requests, some of which return a response.…
1
vote
2 answers

UDP protocol with TaskCompletionSource and async/await

I have a library that talks to a hardware device using UDP. The conversation goes something like this: |------------000E------------>| | | |<-----------000F-------------| | …
Ron Inbar
  • 2,044
  • 1
  • 16
  • 26
1
vote
1 answer

WPF , howto to know that a task has completed

I am developping a MVVM WPF app, and I have some task to do. first load files csv and parse it In background don´t block the ui Thread and save the values in the database.To save the rows to the database I need to be with Async Await Task. My…
jolynice
  • 514
  • 1
  • 8
  • 25
1
vote
1 answer

How to cancel a async task that starts a process in C#?

Currently my code runs a checkout from svn and redirections the stdout and stderr to a textbox using two tasks as seen below. I want to be able to cancel the task immediately when a user clicks the StopButton and be able to cancel the download. I…
Ross Rhone
  • 197
  • 3
  • 14
1
vote
1 answer

cancel taskcompletionsource which calls a void method from an API with timeout xamarin forms

I have this non-async Task> which just requests: TaskCompletionSource> tcs = new TaskCompletionSource>(); ObservableCollection results = new…
1
vote
1 answer

TaskCompletionSource usage in IO Async methods

The implementation of the ExecuteNonQueryAsync() method in System.Data.SqlClient.SqlCommand is as follows: public override Task ExecuteNonQueryAsync(CancellationToken cancellationToken) { …
Helic
  • 907
  • 1
  • 10
  • 25
0
votes
0 answers

Program halts / blocks when calling method that returns TaskCompletionSource.Task

Problem: Application "goes quiet" when awaiting a method that returns TaskCompletionSource.Task from inside JobWasExecuted() that is being called by Quartz. Scenario: I have a program that use Quartz to schedule a job. Since I simply want a…
user1323245
  • 638
  • 1
  • 8
  • 20
0
votes
1 answer

Use TaskCompletionSource with generic Type as parameter

I am currently refactoring a bit of code which has two extremly similar methods. Both methods use a TaskCompletionSource with a bool on one side and a string on the other. Now both of those methods have a bit of code that reads the Task of the…
Sigmarod
  • 85
  • 12
0
votes
0 answers

TaskCompletionSource restarts api call

So I've ASP .NET application that exposes two endpoints. One for starting a continuous Task and other to time it out My controller looks something like this public class SomeController: ControllerBase { private readonly ISomeService _service; …
0
votes
0 answers

Synchronous continuation when calling TaskCompletionSource.SetResult

When calling SetResult on a TaskCompletionSource in C#, is it possible to force the continuations to be called on the same thread, so that SetResult doesn't return until all continuations have executed? Example: using System; using…
ANisus
  • 74,460
  • 29
  • 162
  • 158
0
votes
1 answer

Strange case involving TaskContinuationOptions.RunContinuationsAsynchronously

async void Main() { T0.TT(); } private class T0 { [ThreadStatic] private static int test; public static async void TT() { test = 4; var continuation = new…
Joshua
  • 40,822
  • 8
  • 72
  • 132
0
votes
1 answer

How to convert this WebSocket pattern to a Task I can await/cancel/continuewith/

I have 3rd party WebSocket that I need to consume where the request is sent in one method and the response is given in another. How can I convert this type of pattern to a more typical async/await TPL Task that will support cancellation (via…
0
votes
0 answers

C# TaskCompletionSource error when awaiting dependency service

I'm trying to implement TaskCompletionSource to stop code executing until the dependency service method has completed, but am getting an error when trying to return the TaskCompletionSource result public interface IImageFetcher { …
Ryn9011
  • 179
  • 2
  • 17