Linked Questions
11 questions linked to/from Task constructor vs Task.Run with async Action - different behavior
0 votes
1 answer
366 views
await Task does not wait [duplicate]
I have a simple taken form MS documentation implementation of generic throttle function. public async Task RunTasks(List<Task> actions, int maxThreads) { var queue = new ...
0 votes
1 answer
710 views
Why Task stops executing on call any async method if I create it with new Task(action) -> .Start() instead of Task.Run()? [duplicate]
I found out that if construct a new task using the following way: var task = new Task(async action); task.Start();, the any call of any async method (await Task.Delay(), await new WebClient()....
0 votes
2 answers
400 views
Task.WhenAll is not waiting [duplicate]
I have below code, which should wait 10seconds. Problem is that it completes immediately, the WhenAll method is not working - what am I doing wrong here? public class WhenAllIsNotWorking { public ...
0 votes
0 answers
58 views
Using async/await in a task [duplicate]
I want create a task, which itself calls a async method. var task = new Task(async () => { var res = await asyncMethod(); Console.WriteLine("Async"); }); task.Start(); Task....
60 votes
3 answers
45k views
Waiting for async/await inside a task
I have this construct in my main(), which creates var tasks = new List<Task>(); var t = Task.Factory.StartNew( async () => { Foo.Fim(); await Foo.DoBar(); }); /...
5 votes
3 answers
5k views
Use async in lock statement
I using ASP.NET Core Identity, with Jmeter app I send multiple requests to my web application for create user and it created multiple users with same email, although my RequireUniqueEmail is true ...
3 votes
2 answers
7k views
How to start async Task objects
I want to start a collection of Task objects at the same time and wait until all are complete. The following code shows my desired behaviour. public class Program { class TaskTest { ...
5 votes
2 answers
2k views
Cold Tasks and TaskExtensions.Unwrap
I've got a caching class that uses cold (unstarted) tasks to avoid running the expensive thing multiple times. public class AsyncConcurrentDictionary<TKey, TValue> : System.Collections....
1 vote
1 answer
903 views
Async await still blocking the UI in C#
I used following code to execute the SourceCreator method without blocking UI. string a =null; private string SourceCreator() { string sum = textBox7.Text; sum = sum.Replace(" ", &...
3 votes
1 answer
93 views
Why the TaskCompleted is executed before the end of the operation
I created a task like the following code Task task = new(async () => { // without await Task Delay dont work await Task.Delay(TimeSpan.FromSeconds(5)); Console.WriteLine("Task is ...
-1 votes
2 answers
118 views
Task.Delay unexpected behavior
I have this metod: public async Task StartAsync(Task process) { if (process is null) { throw new ArgumentNullException(nameof(process)); } var loading = ...; await Task....