473,513 Members | 2,624 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

c# and updating the gui from a thread

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).

Aug 25 '06 #1
2 1192
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

Aug 25 '06 #2
oh my god - that's awesome

Marc Gravell wrote:
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
Aug 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4892
by: Hal Vaughan | last post by:
First, I am aware of both SwingUtilities.invokeLater(), and of using Thread to create a new thread.  These are part of the problem. I want to have something running in the background, while the...
0
1285
by: Eric Williams | last post by:
Hello all, I'm working on a little application using PyQt. The main window is just a dialog with 2 progress bars and a few labels. In its original form, the dialog started, then ran a function...
1
1397
by: Joshua Russell | last post by:
Firstly my main method is like this: static void Main(string args) { // New Form Thread FormHandler myFormHandler = new FormHandler(); ThreadStart myThreadStart = new...
1
1996
by: P | last post by:
Hello, I am having a difficult time updating a record via a stored procedure using the gridview and sqldatasource. I cannot seem to be able to find a way to set everything up so that I can pass...
14
2913
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
1
1316
by: sklett | last post by:
I have been doing research on updating the UI while doing time intensive processing. Basically, I have a click event in my Form that will call a member function on one of my business objects, that...
5
12487
by: Mark R. Dawson | last post by:
Hi all, I may be missing something with how databinding works but I have bound a datasource to a control and everything is great, the control updates to reflect the state of my datasource when I...
1
1951
by: batista | last post by:
Hello all, I have a third praty grid control...named C1grid. Im using it in one of my apps.. Now, I have bind this grid to a custom dataset class named "DataViewEx". The code of the class is...
2
4690
by: archana | last post by:
Hi all, I am having application wherein i am using asynchronous programming and using callback i am updating one label control. My question is can i use lock statment to lock control. If yes...
0
1551
by: Code Monkey | last post by:
Suppose I have a windows form (.exe) that has a load of labels and text boxes on it. I enter a number into one of the text boxes and hit the search button. This then launches another thread,...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.