Executing Tasks from C#

Faced with a problem that I can’t execute Task immediately after caching. Not sure if I’m doing something wrong or if it’s a problem with the chosen solution.

In short, what’s going on here. There is S3 compliant storage that I want to work with and I have chosen AWSSDK.S3 nuget for this. It uses asynchronous calls. But the thing is, you have to cache these calls each time before sending them. And it turns out that I can’t call the function I need with a button - I have to cache it first, then call the execution of the task.

Am I doing something wrong? Maybe I’m missing something?

I’ve tried pure code, now I’ve written a helper. But neither of them works as expected.

Example patch or repository would be good…

put the toobservable in the cache region.
or use a managetask region, which does the same internally

1 Like

@sebl thank you very much!
This is exactly how it should be done!

I completely forgot about ManageTask, great tool if you use Tasks.

@antokhio NuGet Gallery | AWSSDK.S3 3.7.414.1

@sebl Might you have some thoughts on how to develop the following idea: creating a chain of calls? When I use ManageTask I get an Observable and can use ForEach for example. But if I use ManageTask inside ForEach (Observable), I get Observable<Observable>. What is the best way to preserve the Async structure and still easily create call chains?

Please have a look at the HowTo Chain Tasks from the Helpbrowser in the previews. The patch shows Then, Then (Value) and ThenDo regions for chaining tasks.

Best,
Anton

2 Likes

@robotanton Thank you so much! Very valuable insight!
I’ve already wrapped everything in ManageTask
Is there something similar for Observable? Although perhaps a scheme with channels would be even more convenient!

Wow, yep, very valuable indeed. Thanks for this one!