PC Review


Reply
Thread Tools Rate Thread

Control.Invoke() throws ArgumentException

 
 
Reinhold Schalk
Guest
Posts: n/a
 
      14th Nov 2003
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


 
Reply With Quote
 
 
 
 
Reinhold Schalk
Guest
Posts: n/a
 
      14th Nov 2003
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

"Reinhold Schalk" <(E-Mail Removed)> schrieb im Newsbeitrag
news:#(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Serg Kuryata [MS]
Guest
Posts: n/a
 
      14th Nov 2003
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" <(E-Mail Removed)>
| References: <#(E-Mail Removed)>
| 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: <(E-Mail Removed)>
| 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
|
| "Reinhold Schalk" <(E-Mail Removed)> schrieb im Newsbeitrag
| news:#(E-Mail Removed)...
| > 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
| >
| >
|
|
|

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RegexStringValidatorAttribute throws ArgumentException Sven Neumann Microsoft Dot NET Framework 3 23rd Nov 2008 05:30 AM
IImage.Draw() throws mysterious ArgumentException =?Utf-8?B?Unlhbg==?= Microsoft Dot NET Compact Framework 0 3rd Jul 2007 12:24 AM
Marshal.PtrToStructure throws ArgumentException Jay Microsoft C# .NET 1 26th Jan 2006 08:49 AM
System.Windows.Forms.Control.Invoke() throws ArgumentException aftersp1 Nicki Carstensen Microsoft Dot NET Framework Forms 1 16th Nov 2004 08:22 AM
Control.Invoke causes ArgumentException Amit Chopra Microsoft Dot NET Compact Framework 1 10th Oct 2003 06:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:20 PM.