函数调用的子例程是否必须完成才能让函数继续执行?
如果在函数内调用子例程,该函数是否总是等到该子例程完全完成后才继续执行该函数的其余部分?如果是这样,有什么办法让它不等待并继续执行其余的功能,而不关心子例程中发生了什么?
If a subroutine is called within a function, does the function always wait until that subroutine is completely finished before it will proceed with the rest of the function? If so, is there any way to make it not wait and continue on with the rest of function and not care what happens in the subroutine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简短的答案是“异步方法调用”,这导致了非常广泛的问题“如何异步运行方法”。答案取决于要求。
您可能想从这里开始:异步编程设计模式。
The short answer is 'asynchronous method call', which leads to very broad question 'how to run method asynchronously'. And the answer depends on the requirements.
You might want to start from here: Asynchronous Programming Design Patterns.
在正常情况下,是的,调用是同步的。也就是说,当您从函数调用子例程时,子例程将完全执行,并且只有完成后才会在调用函数中恢复执行。
你需要使用异步编程来实现你想要的。
有关详细信息,请参阅 MSDN 上的异步调用同步方法。
In the normal course of things yes, the calls are synchronous. That is, when you make a call to a subroutine from a function, the subroutine will fully execute and only when finished will execution resume in the calling function.
You need to use asynchronous programming to achieve what you want.
See Calling Synchronous Methods Asynchronously on MSDN for details.
是的,您应该使用 BeginInvoke 异步调用您的子例程。看看这篇文章:
http://msdn.microsoft.com/en-我们/库/2e08f6yc(v=VS.100).aspx
Yes, you should asynchronously call your subroutine by using BeginInvoke. Check out this article:
http://msdn.microsoft.com/en-us/library/2e08f6yc(v=VS.100).aspx