All Questions

431
votes
19answers
334272 views

Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on

I have a scenario. (Windows Forms, C#, .NET) There is a main form which hosts some user control. The user control does some heavy data operation, such that if I directly call the UserControl_Load me...
521
votes
18answers
659849 views

How do I invoke a Java method when given the method name as a string?

If I have two variables: Object obj; String methodName = "getName"; Without knowing the class of obj, how can I call the method identified by methodName on it? The method being called has no param...
333
votes
6answers
154469 views

What's the difference between Invoke() and BeginInvoke()

Just wondering what the difference between BeginInvoke() and Invoke() are? Mainly what each one would be used for. EDIT: What is the difference between creating a threading object and calling invok...
150
votes
5answers
265638 views

Reflection: How to Invoke Method with parameters

I am trying to invoke a method via reflection with parameters and I get: object does not match target type If I invoke a method without parameters, it works fine. Based on the following code if ...
236
votes
13answers
675634 views

What could cause java.lang.reflect.InvocationTargetException?

Well, I've tried to understand and read what could cause it but I just can't get it: I have somewhere in my code this: try{ .. m.invoke(testObject); .. } catch(AssertionError e){ ... } catch(...
36
votes
5answers
36944 views

Best Way to Invoke Any Cross-Threaded Code?

I know that this question has been asked before, but I'm looking for a way to: streamline the creation of safe cross-threaded code. reuse this code in any situation (no Windows Forms references). ...
67
votes
9answers
192507 views

Invoke(Delegate)

Can anybody please explain this statement written on this link Invoke(Delegate): Executes the specified delegate on the thread that owns the control's underlying window handle. Can anybody explain...
38
votes
3answers
44876 views

How to call a method stored in a HashMap? (Java)

I have a list of commands (i, h, t, etc) that the user will be entering on a command line/terminal Java program. I would like to store a hash of command/method pairs: 'h', showHelp() 't', teleport() ...
32
votes
3answers
7822 views

Is it appropriate to extend Control to provide consistently safe Invoke/BeginInvoke functionality?

In the course of my maintenance for an older application that badly violated the cross-thread update rules in winforms, I created the following extension method as a way to quickly fix illegal calls w...
49
votes
7answers
41832 views

MethodInvoker vs Action for Control.BeginInvoke

Which is more correct and why? Control.BeginInvoke(new Action(DoSomething), null); private void DoSomething() { MessageBox.Show("What a great post"); } or Control.BeginInvoke((MethodInvoker) ...

Previous Next