I have a worker thread that calls MyForm.Invoke(MyEventDelegate), however
once the code hits the invoke method, the thread dies.

Try/Catch doesn't even catch an exception.

Any ideas? I'm using .NET CF SP2

Thanks

--ROBERT

Re: Invoke Problem by Robert

Robert
Wed Oct 06 14:27:01 CDT 2004

Nevermind. Apparantly SP2 has to be installed manually on the emulator.
You'd think that would be in the readme or something....


--ROBERT

"Robert Bouillon" <djwhizzard@hotmail.com> wrote in message
news:eIlPxZ9qEHA.3428@TK2MSFTNGP11.phx.gbl...
> I have a worker thread that calls MyForm.Invoke(MyEventDelegate), however
> once the code hits the invoke method, the thread dies.
>
> Try/Catch doesn't even catch an exception.
>
> Any ideas? I'm using .NET CF SP2
>
> Thanks
>
> --ROBERT
>
>



Re: Invoke Problem by Compulim

Compulim
Wed Oct 06 20:13:43 CDT 2004

In .NET CF, you must use "EventHandler" delegate for "Form.Invoke" method.

You could make a simple EventDispatcher to dispatcher the job with custom
delegate and event arguments.

I wrote a handy dispatcher for synchronizing events between worker thread
and form thread. The code is adhered below:

*** START of EventDispatcher.cs ***
using System;
using System.Windows.Forms;

namespace MyApplication {
public sealed class EventDispatcher {
public static void Invoke( Control control, EventHandler handler, object
sender, EventArgs args ) {
control.Invoke( new EventHandler( new EventDispatcher( handler, sender,
args ).ProxyHandler ) );
}

private EventDispatcher( EventHandler realHandler, object sender,
EventArgs args ) {
this._realHandler = realHandler;
this._sender = sender;
this._args = args;
}

private EventHandler _realHandler;
private object _sender;
private EventArgs _args;

private object Sender {
get { return( this._sender ); }
}

private EventArgs Args {
get { return( this._args ); }
}

private EventHandler RealHandler {
get { return( this._realHandler ); }
}

private void ProxyHandler( object sender, EventArgs args ) {
this.RealHandler( this.Sender, this.Args );
}
}
}
*** END ***

Hope it helps.


Compulim @ kasuei

"Robert Bouillon" <djwhizzard@hotmail.com> wrote in message
news:eIlPxZ9qEHA.3428@TK2MSFTNGP11.phx.gbl...
>I have a worker thread that calls MyForm.Invoke(MyEventDelegate), however
> once the code hits the invoke method, the thread dies.
>
> Try/Catch doesn't even catch an exception.
>
> Any ideas? I'm using .NET CF SP2
>
> Thanks
>
> --ROBERT
>
>