如何等待/异步工作的?

编程入门 行业动态 更新时间:2024-10-19 11:36:38
本文介绍了如何等待/异步工作的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设线程A使用等待,等待的东西在线程B.完成,而B是忙于工作负载,A被认为已经标有悬挂点。并在执行流程将继续暂停code座的来电显示的方法。当B完成后,它会通知从悬挂点继续进行。

Suppose thread A use 'await' to wait for something to finish on thread B. while B is busy with the workload, A is considered to have been marked with a 'suspension point'. And the execution flow in A will continue with the 'caller' method of the suspended code block. When B is done, it will notify A to continue from the suspension point.

我的问题是:

  • 什么是上下文信息的内容保持悬挂点?

  • What is the content of the context info kept for the suspension point?

要如何保存上下文信息?

How is the context info be stored?

如何乙通知有关它的完成?

How does B notify A about it's completion?

是一个怎么的上下文信息恢复? (我认为一旦恢复A的上下文信息,A就会从悬挂点自然恢复)

How is the context info of A restored? (I think once the context info for A is restored, A will resume from the suspension point 'naturally')

什么分别是异步的效果,对编译器'等待'。换句话说,有什么特殊的工作做编译器做的帘子后面。

What's the effect of 'async' and 'await' on compiler, respectively. In other words, what special work does the compiler do behind the curtain.

推荐答案

首先,忘记线程。 异步和等待都很少做线程和多更多的是与重写方法,使您可以使用连续传球风格更容易。

First, forget threads. async and await have very little to do with threading and much more to do with rewriting methods so you can use continuation passing style more easily.

我建议你阅读我的 异步 / 的await 介绍后,然后跟进的的 MSDN文档(这是相当不错)。这会回答你所有的问题除了最后一个,这是最好的回答乔恩飞碟双向的eduasync博客系列。

I recommend you read my async/await intro post and then follow up with the MSDN documentation (which is quite good). That would answer all your questions except the last one, which is best answered by Jon Skeet's eduasync blog series.

更多推荐

如何等待/异步工作的?

本文发布于:2023-11-08 20:25:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1570369.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!