RE: Delegates & Asynchronous Callback
- From: Brian Delahunty <BrianDelahunty@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 11 Aug 2005 03:18:02 -0700
Technically speaking, yes it could. This is because the "LongRunningProcess"
is running on a different thread and the asynchronous callback will happen on
the same thread that the "LongRunningProcess" is running on.
If the system changed threads after your call to invoke it is conceivable
that the callback could happen before the call to ShowDialog. It's very
unlikely but if it did happen it would be very hard to debug.
--
Brian Delahunty
Ireland
http://briandela.com/blog
"standogan@xxxxxxxxx" wrote:
> I have a long running process, and I use Delegates to start it, and
> during the process I want to show a wait form to the user.
>
> ///////////////////CODE/////////////////////////////////
>
> public void StartProcess()
> {
> MyDelegate del = new MyDelegate(LongRunningProcess);
> del.Invoke(new AsyncCallback(CloseWaitForm), null);
>
> waitForm.ShowDialog(this);
> }
>
> public void CloseWaitForm(IAsyncResult result)
> {
> waitForm.HideYourself();
> Application.DoEvents();
>
> AsyncResult ar = (AsyncResult) result;
> MyDelegate del = (MyDelegate)ar.AsyncDelegate;
> del.EndInvoke(ar);
> }
>
> ////////////////////////////////////////////////////////
>
> If in the LongRunningProcess() an exception occurs, and invoke ends
> (CloseWaitForm calls), can it be before the line in which I show the
> form? I mean, invoke ends and waitForm hides, before it is shown, then
> it shows up and stays there forever. Is this a possibility? If it is
> how I can avoid it?
>
> Best Regards...
>
>
.
- References:
- Delegates & Asynchronous Callback
- From: standogan
- Delegates & Asynchronous Callback
- Prev by Date: Re: How to get/set a session token
- Next by Date: Re: catch acrobat "document failed to print" error
- Previous by thread: Delegates & Asynchronous Callback
- Next by thread: Re: Delegates & Asynchronous Callback
- Index(es):