Delegating a task in and getting notified when it completes (in C#)

前端 未结 7 866
灰色年华
灰色年华 2020-12-06 18:06

Conceptually, I would like to accomplish the following but have had trouble understand how to code it properly in C#:


SomeMethod { // Member of AClass{}
            


        
7条回答
  •  失恋的感觉
    2020-12-06 18:20

    Although there are several possibilities here, I would use a delegate, asynchronously called using BeginInvoke method.

    Warning : don't forget to always call EndInvoke on the IAsyncResult to avoid eventual memory leaks, as described in this article.

提交回复
热议问题