Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Concrete command uses Thread.Sleep(1000) to simulate a real command that takes a while to execute. It should run asynchronously with other tasks. Wait command uses Thread.Sleep(5000) because it should keep other commands from being initialize. I can't use await Task.Delay because the whole point of wait is to keep it from continuing. Commented Oct 16, 2020 at 18:39
  • I am afraid you do not understand what await does given your comment above. Better read the excellent documentation. Not to be mean but it does help I think.learn.microsoft.com/en-us/dotnet/csharp/programming-guide/… Commented Oct 16, 2020 at 18:42
  • 1
    @Myntekt If you want it to run concurrently, do not await Task.Run. Commented Oct 16, 2020 at 18:53
  • 1
    The await key keyword stops the current execution and waits at this point for the return from an asnyc function/method (so this execution thread will not block other threads). As your ConcreteCommand does not return any value, you may not need to await it's return. But maybe you take the hint from @PeterBons, async does not necessarily means parallel execution. Commented Oct 16, 2020 at 19:41
  • 1
    @PeterBons think we misunderstood, I wanted to tell Myntekt that he should read your suggested tutorial, since he apparently expects await / async to run in parallel in general. I fully agree with you Commented Oct 16, 2020 at 20:30