Extremely useful one, thanks Nick. I would request similar content on the exception handling, Task cancellation in functions which are async returning Task.
Concept would be basically the same. You use the async keyword in the signature of any method or function you wish to make asynchronous, and then you can await the code from another async method or function
I appreciate the clear spoken English lol. You never know these days in the programming world. The button call returns a void, not Task, therefore it cannot be awaited. Is that good practice? May also be not handy during tests or bug hunting.
I quickly made something for you: *************************************************************************************************** Per MS Documentation: The await operator suspends evaluation of the enclosing async method until the asynchronous operation represented by its operand completes. The await operator doesn't block the thread that evaluates the async method. When the await operator suspends the enclosing async method, the control returns to the caller of the method. *************************************************************************************************** */ internal class Program { public static async Task DoStuffAsync() { for (int i = 1; i < 6; i++) Console.WriteLine(i); await Task.Delay(2000); return "Done: DoStuffAsync"; } static async Task Main(string[] args) { Task DoStuffTask = DoStuffAsync(); Console.WriteLine("Hehe, lemme sneak in here :)"); await DoStuffTask; Console.WriteLine(DoStuffTask.Result); } }
Thank you! What is the purpose of surrounding your http call with a using statement? I've seen this kind of coding before but not really sure why it's used...
Usually, the using in the manner is to provide automatic disposal of the object that is created. As Nick says here, the purists might argue about its use here, but the idea of disposal of objects is to avoid memory leaks. 😀
It closes the connection (security issue) in this case and marks used resources for cleanup (the system decides when to do that exactly). Using this is a good habit and often indispensable in serious code. Is also used, for example when addressing databases. Very important and good habit!
@@angel_macharielMuch appreciated, I was starting to code back then and now I 've seen it more, do you know any youtube vide that goes through this topic more in depth? Thanks again
The using statement is nicely explained on the Microsoft website "using statement - ensure the correct use of disposable objects".' It's not some rocket science to solve, it's more about getting used to it.
Could u do a video explaining the concepts of parameters in API, I mean with restsharp, how to insert headers, body, authorization and comparing that to postman
This is the most helpful video I've found on this stubject. Simple, well explained, and succint. Thank you!
Extremely useful one, thanks Nick. I would request similar content on the exception handling, Task cancellation in functions which are async returning Task.
Great suggestion!
Fantastic stuff! Thank you!
Glad you enjoyed it!
Thanks for uploading this video. Could you please demonstrate the async await concept in a c# console application if possible.
Concept would be basically the same. You use the async keyword in the signature of any method or function you wish to make asynchronous, and then you can await the code from another async method or function
Thanks for the excellent walkthrough!
My pleasure!
I appreciate the clear spoken English lol. You never know these days in the programming world.
The button call returns a void, not Task, therefore it cannot be awaited. Is that good practice? May also be not handy during tests or bug hunting.
Excellent point 👍
Nice Video, Thanks for the Help:)
Easy pizzy. Thanks. I had forgotten the syntax
good video with clear examples given. Thanks!
You are welcome!
well explained
Could you make a video explaining these concepts using C++/CLI ?
Might look at this in future when I revisit c++ 👍
I quickly made something for you:
***************************************************************************************************
Per MS Documentation: The await operator suspends evaluation of
the enclosing async method until the asynchronous operation represented by its operand completes.
The await operator doesn't block the thread that evaluates the async method. When the await operator
suspends the enclosing async method, the control returns to the caller of the method.
***************************************************************************************************
*/
internal class Program
{
public static async Task DoStuffAsync()
{
for (int i = 1; i < 6; i++)
Console.WriteLine(i);
await Task.Delay(2000);
return "Done: DoStuffAsync";
}
static async Task Main(string[] args)
{
Task DoStuffTask = DoStuffAsync();
Console.WriteLine("Hehe, lemme sneak in here :)");
await DoStuffTask;
Console.WriteLine(DoStuffTask.Result);
}
}
Thank you! What is the purpose of surrounding your http call with a using statement? I've seen this kind of coding before but not really sure why it's used...
Usually, the using in the manner is to provide automatic disposal of the object that is created. As Nick says here, the purists might argue about its use here, but the idea of disposal of objects is to avoid memory leaks. 😀
It closes the connection (security issue) in this case and marks used resources for cleanup (the system decides when to do that exactly).
Using this is a good habit and often indispensable in serious code. Is also used, for example when addressing databases. Very important and good habit!
@@angel_macharielMuch appreciated, I was starting to code back then and now I 've seen it more, do you know any youtube vide that goes through this topic more in depth? Thanks again
The using statement is nicely explained on the Microsoft website "using statement - ensure the correct use of disposable objects".'
It's not some rocket science to solve, it's more about getting used to it.
Could u do a video explaining the concepts of parameters in API, I mean with restsharp, how to insert headers, body, authorization and comparing that to postman