我反复调用BeginInvoke的方法。每次通话后,我都会调用EndInvoke。第二次BeginInvoke呼叫声明已完成。为什么?
问题是,对于第二个调用,在BeginInvoke调用之后,返回的IAsyncResult中的IsCompleted成员被设置为true IMMEDIATELY。
这会导致故障,因为程序会认为第二次调用已完成。
为什么会这样做,以及如何检测第二次调用何时完成?
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);
你介意分享你的代码吗? – 2010-09-23 19:05:10
请显示验证码。不要让我们猜测你做错了什么。 – 2010-09-23 19:05:11
使用代码更新您的问题,而不是将其作为评论发布。 – 2010-09-23 19:13:28