开发者

Does a subroutine called by a function have to finish for the function to proceed?

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?


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜