18 Replies
This thing take long time, await the completion of that thing, in the meantime do other stuff
Isn't await the completion of that thing without blocking the main thread? Unless you do
Task.Run
the code will be halted, isn't that correct?Yes, the current code will be halted, but the thread will be freed for anything else that needs it
result=task<int>.exception vs result=await method
why the exception result is diffrent? await return normal exception ,but task.exception return another exception type(aggregation exception)
There's no "vs" here
Two completely different things
Task.Exception
gets you the exception that caused a given task to end prematurely, or null
if the task did not end prematurely
await Method()
(assuming async Task Method()
) will await the completion of the task returned from that method, freeing the thread to do other work in the meantime
FWIW, as a general rule, you should just be awaiting your async task methods
Don't try to handle the exceptions manually, don't try callbacks, none of thatthe await keyword, followed by anything which results in a task, will wait then for the completion of that task before continuing
hence the task is being awaited
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
meant to send this one lol
https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/
Asynchronous programming - C#
An overview of the C# language support for asynchronous programming using async, await, Task, and Task
@eid for more in depth about this please look at the link I sent,
if you're looking at async await then that article is basically a requirement. you need to understand the concepts in more detail
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
I disagree, the article seems well suited to explaining asynchronicity.
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
It explicitly states that there is no parallelism involved in the example model:
Cooking breakfast is a good example of asynchronous work that isn't parallel.and
For a parallel algorithm, you'd need multiple cooks (or threads).looking at the three diagrams I can see no paralellism involved
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
That's just like, your opinion, man.
Unknown User•5mo ago
Message Not Public
Sign In & Join Server To View
I want to change backgroundworker with async/await. In my current scenario i had a backgroundworker declared in the controller. it has two method dowork and RunWorkerCompleted there. So my UI has call controller function that call backgroundworker.RunWorkerAsync().. how i change all this to async/await ?
Please start your own topic/thread, reviving stale issues with new questions is not recommended.