Replies: 1 comment 1 reply
-
如果fun1是一个数据库请求,当前线程可以不用阻塞(线程不会阻塞意味着可以接受更多的请求,提高应用吞吐量),先去干其他事,等处理结果回来了再继续执行(可以在原先线程上也可以在另外一个线程),异步是用来提高线程利用率的,并不是多个任务同时干的那种感觉 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
听了UP主讲的异步编程入门,对于WPF和Winform异步编程的使用好像明白了,不会阻塞主线程,但是对于控制台程序的WEBAPI会有什么好处?切换了线程和不切换线程有什么区别?
var res1=await fun1();
var res2=await fun2(res1);
想问下这个例子,fun2需要拿到fun1的结果才能执行,使用异步有什么优势?
Beta Was this translation helpful? Give feedback.
All reactions