Control.Invoke() throws ArgumentException

R

Reinhold Schalk

Hello,
i have the following problem: i'm trying to modify UI controls from a long
running worker thread. The thread function itself is a method of my Form
class. Now i wanted to use Control.Invoke() to change the current thread
context to the UI thread for updating my controls. I use a custom delegate

delegate void MethodCaller();

My thread functions looks like:

private void AsyncInitializeData() {
MethodCaller method = new MethodCaller(InitializeData);
...
this.Invoke(method); // throws ArgumentException
...
}

private void InitializeData() {
...
}

The call to Control.Invoke(Delegate); does always throw a ArgumentException
without additional info.
I do not know what's going on.

Any help is appreciated.
Thanks in advance
Reinhold
 
R

Reinhold Schalk

Hello,
i'm sorry for posting too early: i think i've got a solution - not quite
satisfactory, but it seems to work now.
i was a little bit confused about the MSDN documentation of VS.NET 2003
concerning Control.Invoke(): "...The delegate can also be an instance
of...or any other delegate type that takes a void parameter list...". Now
this seems not to be quite correct: the only delegate type that does the
correct thing is of type EventHandler. A delegate type which takes a void
parameter list throws ArgumentException.

Reinhold
 
S

Serg Kuryata [MS]

Yes, you are right. The only delegate type for Control.Invoke() that is
supported by the .NET Compact Framework v1.0 is of type EventHandler.

Best regards,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Reinhold Schalk" <[email protected]>
| References: <#[email protected]>
| Subject: Re: Control.Invoke() throws ArgumentException
| Date: Fri, 14 Nov 2003 14:59:28 +0100
| Lines: 48
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: pd9e539f9.dip.t-dialin.net 217.229.57.249
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:38602
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hello,
| i'm sorry for posting too early: i think i've got a solution - not quite
| satisfactory, but it seems to work now.
| i was a little bit confused about the MSDN documentation of VS.NET 2003
| concerning Control.Invoke(): "...The delegate can also be an instance
| of...or any other delegate type that takes a void parameter list...". Now
| this seems not to be quite correct: the only delegate type that does the
| correct thing is of type EventHandler. A delegate type which takes a void
| parameter list throws ArgumentException.
|
| Reinhold
|
| | > Hello,
| > i have the following problem: i'm trying to modify UI controls from a
long
| > running worker thread. The thread function itself is a method of my
Form
| > class. Now i wanted to use Control.Invoke() to change the current thread
| > context to the UI thread for updating my controls. I use a custom
| delegate
| >
| > delegate void MethodCaller();
| >
| > My thread functions looks like:
| >
| > private void AsyncInitializeData() {
| > MethodCaller method = new MethodCaller(InitializeData);
| > ...
| > this.Invoke(method); // throws ArgumentException
| > ...
| > }
| >
| > private void InitializeData() {
| > ...
| > }
| >
| > The call to Control.Invoke(Delegate); does always throw a
| ArgumentException
| > without additional info.
| > I do not know what's going on.
| >
| > Any help is appreciated.
| > Thanks in advance
| > Reinhold
| >
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top