了解线程,异步和等待 [英] Understanding Thread, Async and await

查看:66
本文介绍了了解线程,异步和等待的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我正在尝试学习高级C#并坚持使用线程异步并等待。请解释我的问题:



a)当我定义一个线程时这是什么意思?


              - 定义它的方法是否成为线程?


              - 或者ThreadStart中的参数是否成为线程?


b)我是否只在异步函数中使用await?


  c)如何? async并等待简单的工作?



谢谢

解决方案

< blockquote>

这些问题实在太模糊,无法在论坛中回答。此外,这些类型的问题已经在论坛和在线多次被问及和回答。请搜索这些问题的答案。如果您有任何详细的
问题,那么我们可能会回答,但有关此问题的许多文章和博客更容易解释一般性问题。


线程
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/threading/

https://docs.microsoft.com/en -us / dotnet / standard / threading / using-threads-and-threading


Await / async


https://docs.microsoft.com / en-us / dotnet / csharp / programming-guide / concepts / async / index


https://docs.microsoft.com/en-us/dotnet/csharp/language-reference / keywords / await


https://www.dotnetperls.com/async


https://stackify.com/csharp-async-await -task-performance /


https://stackoverflow.com/questions/14455293/how-and-when-to-use-async-and-await


Michael Taylor

http://www.michaeltaylorp3.net






Hi

I am trying to learn advanced C# and stuck at thread async and await. Please explain my questions:

a) When I define a thread what does this mean?

              - Does the method in which it is defined becomes the thread?

              - Or Does the parameter in ThreadStart becomes the Thread?

b) Do I ONLY use await in async function?

 c) How does async and await work in simple terms?

Thanks

解决方案

These questions are really too vague to be answered in the forums. Additionally these types of questions have already been asked and answered many times in the forums and online. Please search for the answers to these questions. If you have any detailed questions then we may be able to answer but the general questions are more easily explained by the many articles and blogs on the matter.

Threading
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/threading/
https://docs.microsoft.com/en-us/dotnet/standard/threading/using-threads-and-threading

Await/async

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/index

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/await

https://www.dotnetperls.com/async

https://stackify.com/csharp-async-await-task-performance/

https://stackoverflow.com/questions/14455293/how-and-when-to-use-async-and-await

Michael Taylor
http://www.michaeltaylorp3.net


这篇关于了解线程,异步和等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆