【发布时间】:2011-04-16 10:49:26
【问题描述】:
我用 BeginInvoke 反复调用一个方法。每次通话后,我都会调用 EndInvoke。
问题在于,对于第二次调用,返回的 IAsyncResult 中的 IsCompleted 成员在 BeginInvoke 调用之后立即设置为 true。
这会导致故障,因为程序会认为第二次调用已完成。
为什么要这样做,我如何检测第二次调用何时真正完成?
Declarations:
IAsyncResult ar;
Mercury.J4000.Ui.frmMain.doPrintsDelegate printCallback;
The BeginInvoke call:
ar = printCallback.BeginInvoke (jobNameArray, copies, distances, null, null);
The EndInvoke call (in another method):
printCallback.EndInvoke(ar);
【问题讨论】:
-
您介意分享您的代码吗?
-
请出示代码。不要让我们猜你做错了什么。
-
用代码更新您的问题,而不是将其作为评论发布。
-
您需要发布可以重现问题的代码。
标签: c# .net multithreading begininvoke iasyncresult