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
0
votes
0 answers

C# - How to properly wait for data to be supplied by another class asynchronously?

I have an bunch of 'workers' which at some point need an unique key from my HTTP server to continue execution. This keys can sometimes arrive before the workers need them, in which case I just want to supply the worker with the key so it can…
meesg
  • 13
  • 3
0
votes
1 answer

I was wondering if using TaskCompletitionSource is a bad choice

I have to add here I am not a practiced questioner on Stackoverflow so I am glad for feedback concerning why my question might not fit here. Is awaiting a TaskCompletitionSource a bad thing when wrapping a not async call? Here is my use case: I have…
Dr.Bob
  • 98
  • 1
  • 5
0
votes
1 answer

How to continue TaskCompletionSource<> in another thread?

I'm using TaskCompletionSource<> quite often. I have a network protocol design, where I receive many streams in one tcp/ip connection. I demultiplex those streams and then inform the corresponding "SubConnections" of new content. Those…
Matthias
  • 948
  • 1
  • 6
  • 25
0
votes
2 answers

Need to hold the code execution till a property is null using TaskCompletionSource

I have a class Public class DDSModel { public string message {get; set;} } I'm using this class in c# code but I want to hold my code execution till the message property is empty. I have a different method that is filling the property after…
0
votes
1 answer

How to use TaskCompletionSource

I am having a situation of multi-producer and single consumer.I have opted for a common thread-safe resource that in which all producers Enqueue items. However i do not know how to efficiently make the producer await for new items when Dequeue-ing…
0
votes
1 answer

Deadlocks in async method using TaskCompletionSource

I'm trying to expose an ASP.NET Web API which has to capture and return a photo as an attachment. I'm using CameraControl.Devices 2.1.0-beta to control my Nikon DSLR and .NET 4.6. But I'm getting a very inconsistent behavior. Sometimes the first…
0
votes
2 answers

Can not get results of TaskCompletionSource

Hello I have the following problem: I want to perform something similar to a transaction. I want to execute a number of async operations after I receive an external trigger.Therefore I am using a TaskCompletionSource that gets set in a method…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
0
votes
2 answers

Implement a capped and buffered job executor

I want to implement a capped and buffered job executor. It will have a single method: public class CappedBufferedExecutor { public CappedBufferedExecutor(int bufferCapping, int fillTimeInMillisec); public Task EnqueueAsync(string…
Mugen
  • 8,301
  • 10
  • 62
  • 140
0
votes
2 answers

C# TaskCompletionSource not working

I have an interesting problem.. I have a login method which works a WCF service. I created a taskcompletion and waits until result is come. Well problem is, if I call 2 times login method, the second one does not return anything. I put break point…
unbalanced
  • 1,192
  • 5
  • 19
  • 44
0
votes
0 answers

Do I need to observe the Exception property of a Task created by a TaskCompletionSource?

Suppose I have a TaskCompletionSource where I explicitly set its exception via SetException(Exception). Am I still required to access the Exception property of its task to avoid the "A Task's exception(s) were not observed either by Waiting on the…
Simon
  • 428
  • 5
  • 19
0
votes
1 answer

Awaiting a TaskCompletionSource that never returns a Task

I am trying to write a unit test around an async pub/sub system. In my unit test, I create a TaskCompletionSource and assign it a value within the subscription callback. Within the subscription callback, I unsubscribe from the publications. The…
Johnathon Sullinger
  • 7,097
  • 5
  • 37
  • 102
0
votes
1 answer

MYOB oauthService.GetTokensAsync not showing dialog

As a result of my question about TaskCompletionSource I tried a similar technique for getting the tokens private t.Task GetOAuthTokens() { var tcs = new t.TaskCompletionSource(); t.Task.Run( …
Kirsten
  • 15,730
  • 41
  • 179
  • 318
0
votes
0 answers

Handling client-server communication in GUI event based app

Together with my friend, we are making simple chat application. Client is in C# and server in Java. Entire communication is based on WebSockets. I have problem with designing optimal application flow. Currently it's working like this: Steps to…
Marduk
  • 359
  • 4
  • 13
0
votes
0 answers

Make TaskCompletionSource.Task run in background from asp.net mvc request

In one action of my MVC 4 apps, I have a call: public ActionResult Test() { DownloadAsync("uri","file path"); return Content("OK"); } DownloadAsync return a Task and I expect to see the DownloadAsync run in background. But I always see that…
langtu
  • 1,198
  • 1
  • 10
  • 23
0
votes
1 answer

What is the synchronous equivalent of a TaskCompletionSource?

I have a method that goes like this: Task MyMethodAsync() { SendBluetoothMessageAsync(); var tcs = new TaskCompletionSource(); Bluetooth.MessageRecieved += (o, e) => tcs.SetResult(e.SomeProperty); //this removes…
It'sNotALie.
  • 22,289
  • 12
  • 68
  • 103