From 53011ff585289bf7df7e61fd731602637fbb3032 Mon Sep 17 00:00:00 2001 From: Arjun Sapkota Date: Wed, 24 May 2023 21:13:57 +1000 Subject: [PATCH] Task.Run is not necessary, Task.Run is not necessary, it just adds memory overhead. --- dotnet/Program.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/dotnet/Program.cs b/dotnet/Program.cs index 2d556de..8d95d8c 100644 --- a/dotnet/Program.cs +++ b/dotnet/Program.cs @@ -14,12 +14,7 @@ static async Task Main(string[] args) for (int i = 0; i < numTasks; i++) { - Task task = Task.Run(async () => - { - await Task.Delay(TimeSpan.FromSeconds(10)); - }); - - tasks.Add(task); + tasks.add(Task.Delay(TimeSpan.FromSeconds(10))); } await Task.WhenAll(tasks);