Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

c# and updating the gui from a thread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fidel - 25 Aug 2006 04:32 GMT
Hello,

I'm aware of the ways MS has recommended updating the gui from a
thread.

eg.
BeginInvoke(StartedExaminingFile, new object[] { file });

But, I really don't like this solution. The fact that you're passing an
array of objects means if the function signature changes, the invoke
would fail terribly.

With all the code-generation that goes on with .net (ie. datasets etc),
couldn't MS make a wrapper for this call? It just seems
uncharacteristic of .net to not strongly type the parameters,
considering the introduction of things like generics (and other
mechanisms for strongly typing).
Marc Gravell - 25 Aug 2006 05:46 GMT
in 2.0 (which you seem tobe using since you don't have "new
SomeDelegateType(StartedExaminingFile)" you can both strongly type it,
and remove the need for the function to match *any* delegate:

BeginInvoke((MethodInvoker) delegate {StartedExaminingFile(file);});

(or something similar; don't have an IDE to hand...)

The only thing to watch out for is deferred variable evaluation...

Marc
fidel - 25 Aug 2006 06:19 GMT
oh my god - that's awesome

> in 2.0 (which you seem tobe using since you don't have "new
> SomeDelegateType(StartedExaminingFile)" you can both strongly type it,
[quoted text clipped - 7 lines]
>
> Marc

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.