Is Delegate.EndInvoke() really necessary?

前端 未结 7 1944
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 08:28

I\'ve read a couple of forums and even a stackoverflow question or two saying that Delegate.EndInvoke is necessary when using Delegate.BeginInvoke. Many of the articles I\'

7条回答
  •  情话喂你
    2020-11-29 08:49

    The way I've used BeginInvoke is generally with threads that I don't care about when they finish or how long they take to process.

    Sounds like you should consider using the Thread class instead of asynchronous delegates.

    If you care about the results or detecting errors (which both require marshalling the results/error to the originating thread), then you can use asynchronous delegates, and in this case you would need EndInvoke. Better yet, use the Task or Task classes.

    If you just want to spin off some independent operation, then use the Thread class.

提交回复
热议问题