Questions tagged [continuewith]

45 questions
0
votes
1 answer

Dapper - Task Cancelled when continuing an asynchronous operation of fetching objects

I'm working with .Net Core 5.0 and Dapper as ORM. I have the following c# code: public Task> FetchAllFoos1(CancellationToken cancel = default) { string sql = "SELECT * FROM Foos"; var context = new…
Davit
  • 23
  • 5
0
votes
1 answer

Queuing Tasks to Process H.264 Frames using Task.ContinueWith is giving memory issues

My application streams from a camera using the RTSPClientSharp library, there is an OnFramesReceived event that gets raised when a decoded frame is ready. I was converting the decoded frame to a Bitmap in the same Event, This is a blocking call and…
0
votes
2 answers

Chaining sequential async tasks within a ForEach loop: Is this a good way to do it?

I am working on a windows service and I have two related calls that depend on each other, that I want to run asynchronously for each "pair" or "set" of calls. There are several ways to do this and I have tried a few different was and settles on this…
0
votes
2 answers

ContinueWith Method - How to understand it exactly?

So i have e.g. this code here: initialTask.ContinueWith((argument) => { ... }); I understand the second Task is executed once the first one is finished. I have to provide the second Task with an argument though, which is also of Type Task. Is this…
0
votes
2 answers

Thread-safe task queue await

I want to do a simple thing (assuming that ContinueWith is thread-safe): readonly Task _task = Task.CompletedTask; // thread A: conditionally prolong the task if(condition) _task.ContinueWith(o => ...); // thread B: await for everything await…
Sinatr
  • 20,892
  • 15
  • 90
  • 319
0
votes
1 answer

c# async update http then save to local db WhenAll ContinueWith timing

I've got the following code which seems to run fine apart from the continuation on the WhenAll ... await Task.WhenAll(syncTasks).ContinueWith ... is run before all four methods are completed. Would appreciate any guidance on what I'm doing wrong…
ledragon
  • 299
  • 6
  • 17
0
votes
1 answer

Task.ContinueWith not very popular with async code?

We want to execute invoke 10 tasks in parallel and handle each of the 10 results in parallel. to achieve, created a list of tasks and used continuewith each of which are associated to async methods, snippet private async Task>…
0
votes
1 answer

Why does continueWith uses action(of task) as a parameter?

Basically, it asks for a sub with Task as a parameter. That's what Action(of Task) right? Why? I know I can pass normal sub to continueWith. I never remember passing a sub that requires a task parameter.
user4951
  • 32,206
  • 53
  • 172
  • 282
0
votes
2 answers

How to do a task after another task in vb.net?

For Each account In _accounts11 Dim newtask = account.readbalancesAsync() newtask = newtask.ContinueWith(Sub() account.LogFinishTask("Getting Balances", starttime)) newtask = newtask.ContinueWith(Async Function()…
user4951
  • 32,206
  • 53
  • 172
  • 282
0
votes
1 answer

How to do this without lambda?

Public Shared Async Function getMarketDetailFromAllExchangesAsync() As Task Dim taskList = New List(Of Task) Dim starttime = jsonHelper.currentTimeStamp LogEvents("Start Getting Market Detail of All") For Each account In…
user4951
  • 32,206
  • 53
  • 172
  • 282
0
votes
1 answer

Is there a proper pattern for multiple ContinueWith methods

In the docs for TPL I found this line: Invoke multiple continuations from the same antecedent But this isn't explained any further. I naively assumed you could chain ContinueWiths in a pattern matching like manner until you hit the right…
Ingó Vals
  • 4,788
  • 14
  • 65
  • 113
0
votes
1 answer

async POST method C# '': not all code paths return a value

As I'm listening to lots of POST requests I'm trying to do it asynchronous with Promise like methodology. The issue is that it it requires a return value outside of the "getDataLead" task(this case to uncomment the return "good2" part). Any ideas…
0
votes
1 answer

Is reassigning a task value necessary when not using task.ContinueWith()

When reading a post, Starting Tasks In foreach Loop Uses Value of Last Item), the marked answer makes a lot of sense. The author created a new variable, pathCopy, to use in the task. My question is, is this only necessary when Task.ContinueWith()…
Sam Jazz
  • 131
  • 7
0
votes
1 answer

How to use ContinueWith properly when the other task may continue running forever?

How to use ContinueWith properly when there is a chance that the other task may continue running forever? Example: task is infinite but I'm only would like to wait for her only for specific amount of time: var task = Task.Factory.StartNew(() => { …
Shahar Shokrani
  • 7,598
  • 9
  • 48
  • 91
0
votes
1 answer

when the exception property in the Task can have a value?

I want to know when "continueWhith" has exceptions. I made a code like this. Task.Factory.StartNew(() => { if(HasException()) throw new Exception("Exception"); // Logic }).ContinueWith(x => { // Do something to UI. },…
Masuri
  • 894
  • 2
  • 9
  • 19