Hi Frank Liu, Thanks alot for the video. However I have a little question. Is there any difference in parallel vs async programming? If yes, then is this tutorial is for Parallel Programming or is it about async programming?
Hi Shahid, that is a great question! I am not sure if I can explain clearly in a comment, but I will try. To understand what asych is, the easiest way is to think about what synch is: task1, task 2 and task 3 have to run in sequence in other words, they have to run synchronously. Whereas, if task 2 runs before task 1finishes, we call it asynchronous. Here, we are emphasizing the order of executing. Then what is parallelism? Obviously, when two tasks are running at the same time, we say they are running in parallel. Here, we are not emphasizing the sequence, but that there are multiple activities at the same time. However, if you think deeper. In asynchronous programming, there have to be at least two tasks, the main task carried on by the main thread, and the long running task. The task is not blocking nthr the main task because they are running in parallel. So, they are essentially very closely related. Hence, I say that the difference between the two is in emphasis. One is empathizing the order of execution can go out of sync, the other is emphasizing two or more tasks can run at the same time. Because the emphasis is different, the problems the two are trying to resolve are different too. Asynchronous tries to resolve how to continue after the long running task, whereas Parallelism tries to resolve sharing resources/messages between the threads. This tutorial is more about async and less about parallelism because it deals more with how to continue after a long running task. However the two topics are closely related. I hope that helps.
@@FrankLiuSoftware Thanks for the detailed answer. As per my knowledge, in async model, order of execution does not matter. It deals the problem of freezing or waiting when a long running task is executing itself. When we use await keyword, we are saying hey task please execute urself and when u r executing urself, give me the control back so that i can work on other things. So in this case time is switched b/w them for execution (they are not executing at the same time). When.long running task get completed it signals the main calling method that I am done. In case if we are doing async programming using task.run, then it pickup thread from thread pool to execute the task. While in parallel programming model, threads are created to execute the code and they all run in parallel
@@sriaz81 Yes Shahid, you are correct. I worded it in a confusing way. What I meant by "the order of executing" is that after the long running process finishes, something needs to be executed. I was referring to the call back process. With task.run, we have to specify a call back, yet with async and await, we achieve the same result without specifying a call back function. Parallel programming has multi threads run at the same time (same as async), but here we are mainly trying to resolve the shared resources problem: how can the multi threads access the same resource without causing conflicts.
async programming means long time taking tasks like getting input from user or reading from db, but not CPU intensive. While if you think of parallel programming it will be like doing some CPU intensive work processing millions of records.
This is the clearest explanation video about asynchronous programming I've encountered. Thank you very much. You deserve a lot more subscribers. Keeps doing your thing man.
You are absolutely brilliant. Months and browsing endlessly, you had finally made me understand the Task asynchronous topic. You earned a gold medal from me🎉
this is really the best tutorial about async await c# for its simplicity and clearness i ever see, after reading so many microsoft documentation, i am still confused, now you save my ass, Thank you.
Thank you for the clear explanation of the basics of asynchronous programming. I appreciate the way you that start with the basic concept and use very simple examples. Then additional concepts build on top off the previous ones, which builds our understanding step by step. It is an excellent approach to teaching. I learned everything I need to clear my understanding and go forward with correct implementations of asynchronous programming in C#. Many other tutorials on this topic should stop and learn from this one. Focus on teaching the concepts and implementation in simple, clear terms and quit trying to show how good you are at writing code. Many of us get lost in the complexity code you are trying to use as an example. It is a waste of time because the example is too hard to follow (Tim Corey please pay attention). I look forward to viewing more of your content. Subscribed.
Nice video. However, in your Calculate1_2 () method, you have the method signature as, "async static void Calculate1_2 ()". It will cause deadlocks. Instead, it should be, "async static Task Calculate1_2 ()".
@@FrankLiuSoftware Appreciate you putting the link for additional clarity. But I still don’t understand why we have all of these wonderful ways of making a Task run asynchronously with the ability to await other tasks until they are finished but I can’t think of any use cases where this is applicable except for database and file operations.
What is the reason you introduce the last function Test? I run the example using static async Task Calculate1_2() directly and the result is the same as using Test function.. What is the difference? Why do you introduce so many functions?
Hi Frank Liu. Nice Video :). In the end you are creating a Test() - method with "async static void Test()". Is this a misstake? Since the general advice is to avoid "async void" for async methods, other than for event handlers.
Hi Frank, hope you are doing great. Could you please help me on how to process thousands of records in c#. Each record call a service to get some other details based on record id. Currently I am using paralell.foreach and it process 10000 record in an hour. Please suggest me how can I improve performance by 50%.
Hi Md, the method you shall use depends on many factors. For example, the nature of the records you are processing, the way you are processing each record... I would do lots of comparisons and profiling. Have you tried without parallelism? How much time did that take? Have you tried partitioning the data before you do the parallel foreach? Just in case, don't forget to see if there are ways to improve the processing of each record.
Hi Frank Liu, Thanks alot for the video. However I have a little question. Is there any difference in parallel vs async programming? If yes, then is this tutorial is for Parallel Programming or is it about async programming?
Hi Shahid, that is a great question! I am not sure if I can explain clearly in a comment, but I will try. To understand what asych is, the easiest way is to think about what synch is: task1, task 2 and task 3 have to run in sequence in other words, they have to run synchronously. Whereas, if task 2 runs before task 1finishes, we call it asynchronous. Here, we are emphasizing the order of executing.
Then what is parallelism? Obviously, when two tasks are running at the same time, we say they are running in parallel. Here, we are not emphasizing the sequence, but that there are multiple activities at the same time.
However, if you think deeper. In asynchronous programming, there have to be at least two tasks, the main task carried on by the main thread, and the long running task. The task is not blocking nthr the main task because they are running in parallel. So, they are essentially very closely related.
Hence, I say that the difference between the two is in emphasis. One is empathizing the order of execution can go out of sync, the other is emphasizing two or more tasks can run at the same time.
Because the emphasis is different, the problems the two are trying to resolve are different too. Asynchronous tries to resolve how to continue after the long running task, whereas Parallelism tries to resolve sharing resources/messages between the threads.
This tutorial is more about async and less about parallelism because it deals more with how to continue after a long running task. However the two topics are closely related.
I hope that helps.
@@FrankLiuSoftware Thanks for the detailed answer. As per my knowledge, in async model, order of execution does not matter. It deals the problem of freezing or waiting when a long running task is executing itself. When we use await keyword, we are saying hey task please execute urself and when u r executing urself, give me the control back so that i can work on other things. So in this case time is switched b/w them for execution (they are not executing at the same time). When.long running task get completed it signals the main calling method that I am done. In case if we are doing async programming using task.run, then it pickup thread from thread pool to execute the task. While in parallel programming model, threads are created to execute the code and they all run in parallel
@@sriaz81 Yes Shahid, you are correct. I worded it in a confusing way. What I meant by "the order of executing" is that after the long running process finishes, something needs to be executed. I was referring to the call back process. With task.run, we have to specify a call back, yet with async and await, we achieve the same result without specifying a call back function.
Parallel programming has multi threads run at the same time (same as async), but here we are mainly trying to resolve the shared resources problem: how can the multi threads access the same resource without causing conflicts.
async programming means long time taking tasks like getting input from user or reading from db, but not CPU intensive.
While if you think of parallel programming it will be like doing some CPU intensive work processing millions of records.
@@FrankLiuSoftware easiest explanation.. thanks
This is the clearest explanation video about asynchronous programming I've encountered. Thank you very much. You deserve a lot more subscribers. Keeps doing your thing man.
It means you haven’t seen enough videos
Great job, never saw a better tutorial concerning basics of Tasks
You are absolutely brilliant. Months and browsing endlessly, you had finally made me understand the Task asynchronous topic. You earned a gold medal from me🎉
Best video on UA-cam regarding Tasks for beginners.
I still have to dig more into this until it makes absolute sense. Anyways: Thanks Frank.
Glad it was helpful!
Thanks for breaking it down in such an easy to understand way!
this is really the best tutorial about async await c# for its simplicity and clearness i ever see, after reading so many microsoft documentation, i am still confused, now you save my ass, Thank you.
Thanks Frank for giving a detailed explanation.
I consider myself as a slow learner, but this helped alot. THANK YOU!
Glad that it is helpful!
Clear, concise explanation. Great video.
Thanks man. Sat late night and have given us great tutorial.
Hi Frank , Frankly telling its clean and very clear video , thanks for your effort and sharing to others.
You are welcome Adhi!
Thank you so much. Great explanation of Tasks, Async and await.
Thanks Liu. This video help me so much
Thank you for the clear explanation of the basics of asynchronous programming. I appreciate the way you that start with the basic concept and use very simple examples. Then additional concepts build on top off the previous ones, which builds our understanding step by step. It is an excellent approach to teaching. I learned everything I need to clear my understanding and go forward with correct implementations of asynchronous programming in C#. Many other tutorials on this topic should stop and learn from this one. Focus on teaching the concepts and implementation in simple, clear terms and quit trying to show how good you are at writing code. Many of us get lost in the complexity code you are trying to use as an example. It is a waste of time because the example is too hard to follow (Tim Corey please pay attention). I look forward to viewing more of your content. Subscribed.
Thanks a bunch! Helped me out a lot.
best explanantion and clean and simple to understand,, i just liked it very well...
Hello Man, You saved my Day you nailed it. Many thanks !
Glad that it is helpful!
Very very nice explanation
Thank you for posting the video!
Thank you for watching!
This is an amazing explanation.
Thanks Frank Liu!! Great tutorial!
You are welcome!
Thank you Frank, you gave a best example ever.
you are great teacher , it was so clear
Thank you so much!
Thank you man! You definateely need more subscribers huh (EDIT: For a moment at the begining i thought it's a joke (those houses lol))
C# in a home buyer's mind. LOL!
@@FrankLiuSoftware lol
@@FrankLiuSoftware xD
Awesome............Well structured examples.
Awesome work! Thank you
This was a real good and clear tutorial.
Beautiful explanation.
Very well explained. 🔥🔥🔥🔥
just brilliant explanation bro cheers.
You are a great teacher! Thank you for sharing these videos
Thank you Olga!
Such a calm explanation. Thanks.
Nice video. However, in your Calculate1_2 () method, you have the method signature as, "async static void Calculate1_2 ()". It will cause deadlocks. Instead, it should be, "async static Task Calculate1_2 ()".
That is correct. It is correct to use Task. UA-cam doesn't allow you to fix a video once it is uploaded.
Thank you very much for your simple and clear explanation. May God Bless you!
Thank you sir! May God bless you too!
Very good demo. Thanks!!!
Simply superb explanation. 🙏
Glad that it helps.
How your awaiter.GetResult( ) is providing value.. it's return type is void.??.
Thanks for lesson!Can you make more videos about asynchronous programming or concurrency in C#?
It was my plan to do a series of that. But I am still planning. Not sure which one will go next.
Very calm and clear explanation. Thank you indeed Frank #maestro
very good and clear explanation !!!
Thank you Eraz!
Thanks for sharing!!!
Hi Frank Liu, Thanks alot for the video. However I have a little question. What is the difference between Concurrency and Asynchronous?
Check out my answer here: frankliucs.com/async-vs-parallelism-in-c
@@FrankLiuSoftware Appreciate you putting the link for additional clarity. But I still don’t understand why we have all of these wonderful ways of making a Task run asynchronously with the ability to await other tasks until they are finished but I can’t think of any use cases where this is applicable except for database and file operations.
Very well explained. Thank you Frank !
You are very welcome!
What is the reason you introduce the last function Test? I run the example using static async Task Calculate1_2() directly and the result is the same as using Test function.. What is the difference? Why do you introduce so many functions?
Hi Frank Liu. Nice Video :). In the end you are creating a Test() - method with "async static void Test()". Is this a misstake? Since the general advice is to avoid "async void" for async methods, other than for event handlers.
clean explaination
thanks a lot, please upload more...
Nice video man, thanks!!
You helped me a lot. thanks for this video :)
You are very welcome!
love this video ❤
thanks for this wonderful video :)
You are welcome!
Great video!
Thank you Mark!
Hi Frank, hope you are doing great.
Could you please help me on how
to process thousands of records in c#.
Each record call a service to get some other details based on record id.
Currently I am using paralell.foreach and it process 10000 record in an hour.
Please suggest me how can I improve performance by 50%.
Hi Md, the method you shall use depends on many factors. For example, the nature of the records you are processing, the way you are processing each record... I would do lots of comparisons and profiling.
Have you tried without parallelism? How much time did that take? Have you tried partitioning the data before you do the parallel foreach?
Just in case, don't forget to see if there are ways to improve the processing of each record.
讲得好!优秀👍👍
谢谢!很高兴帮助到你!
@@FrankLiuSoftware 技术很棒,英文说的也非常美式,我几乎听不出你的口音
what's a GetAwaiter()
Thank you man
You are welcome!
You did not exaplain the last part. changing return value to Task.
Do you have an example with web api?
What exactly you want to see about web api? I am planning my tutorials, you are welcome to give suggestions! Thanks!
Using Asynchronous and synchronous methods for a web api weather app or news feed app for example
Let me think about it! Thank you so much!
@@FrankLiuSoftware Yes, I'd love to see that. A video on Web API async await will help a lot. Thanks. :-)
Clearly!
Thank you! Xiexie
不客气!
Good explanation, could have been a little faster
en le Aladakatii, Heng idi?
9.32 was the reason i quit the tutorial.
you should have kept it simple
Thank you! I like constructive comments! Appreciated!
Great!
Thank you!
Screen is not clear
#coding
❤❤❤❤❤q