Questions tagged [invoke]

Executes the specified delegate on the thread that owns the control's underlying window handle.

The Invoke method searches up the control's parent chain until it finds a control or form that has a window handle if the current control's underlying window handle does not exist yet. If no appropriate handle can be found, the Invoke method will throw an exception.

1794 questions
18
votes
2 answers

WPF invoke a control

How can I invoke a control with parameters? I've googled this up, but nowhere to find! invoke ui thread This is the error i get: Additional information: Parameter count mismatch. And this happens when i do a simple check whether the text property…
Yustme
  • 6,125
  • 22
  • 75
  • 104
18
votes
7 answers

C# Multithreading -- Invoke without a Control

I am only somewhat familiar with multi-threading in that I've read about it but have never used it in practice. I have a project that uses a third party library that shares the status of an input device by raising events. The problem is, the way…
colithium
  • 10,269
  • 5
  • 42
  • 57
17
votes
2 answers

Python Invoke - Can't find any collection named 'tasks'!

I did the getting started on Python Invoke from invoke import task @task def build(): print("Building!") The expected output is $ invoke build Building! However, my output is $ invoke build Can't find any collection named 'tasks'! I have…
Asoul
  • 996
  • 1
  • 10
  • 22
16
votes
3 answers

MethodInvoke delegate or lambda expression

What is the difference between the two? Invoke((MethodInvoker) delegate { checkedListBox1.Items.RemoveAt(i); checkedListBox1.Items.Insert(i, temp + validity); checkedListBox1.Update(); } ); vs Invoke((MethodInvoker) …
Jack
  • 5,680
  • 10
  • 49
  • 74
16
votes
1 answer

what is invoking?

What is method invoke, control.invoke? What is invoking in general in programming examples : MethodInvoker getValues = new MethodInvoker(delegate() { checkbox1Checked = checkbox1.Checked; textBox6Text = textBox6.Text; textBox7Text =…
BOSS
  • 1,828
  • 11
  • 34
  • 60
16
votes
4 answers

Will multiple Control.BeginInvoke/Invoke calls execute in order?

I need to know whether Control.BeginInvoke and Control.Invoke calls will execute in the order they are called. I have the following scenario: UI thread is blocked WCF thread calls Control.BeginInvoke WCF thread calls Control.Invoke (or possibly…
cornergraf
  • 562
  • 8
  • 22
15
votes
5 answers

Speeding up Reflection Invoke C#/.NET

There are plenty of posts on speeding up reflection invokes, examples here: Speeding up Reflection API with delegate in .NET/C# https://codeblog.jonskeet.uk/2008/08/09/making-reflection-fly-and-exploring-delegates/ and here: Example : Speeding up…
Rob
  • 1,687
  • 3
  • 22
  • 34
14
votes
2 answers

C# How to invoke with more than one parameter

I use the code below to access the properties on my form,but today I'd like to write stuff to a ListView,which requires more parameters. public string TextValue { set { if (this.Memo.InvokeRequired) { …
Ivan Prodanov
  • 34,634
  • 78
  • 176
  • 248
14
votes
2 answers

Parameter count mismatch with Invoke?

The code block below results in the error: TargetParameterCountException was unhandled by user code. Parameter count mismatch. public void AddListViewItem(string[] Data) { if (InvokeRequired) { Invoke(new…
sooprise
  • 22,657
  • 67
  • 188
  • 276
14
votes
1 answer

Why exceptions are not propagated by WPF Dispatcher.Invoke?

Here's my hypothetical example. I have a very simple WPF window with a one Button. The Button.Click event has a handler that goes like this. Action doit = () => { Action error = () => { throw new InvalidOperationException("test"); }; try { …
jpbochi
  • 4,366
  • 3
  • 34
  • 43
13
votes
2 answers

How do I dynamically invoke methods in Groovy?

At runtime I'm grabbing a list of method names on a class, and I want to invoke these methods. I understand how to get the first part done from here: http://docs.codehaus.org/display/GROOVY/JN3535-Reflection GroovyObject.methods.each{ println…
avgvstvs
  • 6,196
  • 6
  • 43
  • 74
13
votes
2 answers

Invoke ToolStripMenuItem

I'm trying to figure out if there's a way to Invoke ToolStripMenuItem. For example,I am calling a web service(ASynchrously) when result is returned.i populate drop down items according to result,(In call back method) …
Zain Ali
  • 15,535
  • 14
  • 95
  • 108
13
votes
5 answers

Run code on UI thread without control object present

I currently trying to write a component where some parts of it should run on the UI thread (explanation would be to long). So the easiest way would be to pass a control to it, and use InvokeRequired/Invoke on it. But I don't think that it is a good…
Martin Moser
  • 570
  • 6
  • 12
13
votes
1 answer

"Object does not match target type" when calling methods using string in C#

I'm trying to call a method using a string, but there a problem: void make_moviment(string mov,Vector3 new_mov){ GameObject past_panel = GameObject.Find(actual_level.ToString()); Type t =…
Bernardo Bacalhau
  • 155
  • 1
  • 1
  • 8
13
votes
5 answers

How to access a field's value via reflection (Scala 2.8)

Consider the following code: class Foo(var name: String = "bar") Now i try to get the value and the correct type of it via reflection: val foo = new Foo val field = foo.getClass.getDeclaredField("name") field.setAccessible(true) //This is where it…
soc
  • 27,983
  • 20
  • 111
  • 215