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
12
votes
3 answers

Why using Action in this code?

Hi I see following code: void UpdateMessage (string message) { Action action = () => txtMessage.Text = message; this.Invoke (action); } Why using Action and then invoke action here? Why not just using txtMessage.Text = message to replace…
spspli
  • 3,128
  • 11
  • 48
  • 75
12
votes
5 answers

Deadlock when invoking the UI thread from a worker thread

I have a deadlock when I invoke the UI thread from a worker thread. Indeed, the worker thread is blocked on the invoke line: return (ucAvancementTrtFamille)mInterfaceTraitement.Invoke(d, new object[] { psFamille }); The weird thing is that the UI…
leo
  • 1,134
  • 1
  • 8
  • 20
12
votes
11 answers

Is there a general "back-end" library for Java reflection

I'm currently working with a specialized, interpreted, programming language implemented in Java. As a very small part of the language, I'd like to add the ability to make calls into Java. Before I dive into all of the nitty-gritty of reflection, I…
Dave Ray
  • 39,616
  • 7
  • 83
  • 82
12
votes
7 answers

PowerShell Pass Named parameters to ArgumentList

I have a PowerShell script that accepts 3 named parameters. Please let me know how to pass the same from command line. I tried below code but same is not working. It assigns the entire value to P3 only. My requirement is that P1 should contain 1, P2…
Parveen Kumar
  • 419
  • 3
  • 7
  • 20
12
votes
4 answers

How does the event dispatch thread work?

With the help of people on stackoverflow I was able to get the following working code of a simple GUI countdown (which just displays a window counting down seconds). My main problem with this code is the invokeLater stuff. As far as I understand…
Roman
  • 124,451
  • 167
  • 349
  • 456
12
votes
1 answer

Using reflection to invoke method on field

My code looks like the following: class MyObject { MyField f = new MyField(); } class MyField { public void greatMethod(); } Is there a way to invoke the greatMethod() using reflection on a object of the class MyObject? I tried the…
priojewo
  • 937
  • 2
  • 11
  • 22
12
votes
2 answers

How do I dynamically invoke or call a class in Rails?

Assuming I can construct a string that matches an existing class, how do I invoke it? For example, I have several classes: MyClass1 MyClass2 MyClass3 And I want to dynamically invoke each of them by constructing a string that matches their names.…
comb
  • 185
  • 2
  • 9
11
votes
3 answers

How do I open a window on a new thread?

I have a options window and a window that displays color based on these options and Kinect data. So far everything's on one thread (as far as I know; I haven't done any threading). Now, I'm adding an option to open a viewer window that will need to…
mikey555
  • 432
  • 3
  • 8
  • 19
11
votes
3 answers

Unable to access UNC Paths in Powershell remote session

I am unable to access the UNC paths on my servers in a Powershell remote session from my local machine. I am able to use them from Servers Cmd prompt directly. Actually, I have logged into the server and mapped a UNC path as local drive (say X:).…
user2610958
  • 113
  • 1
  • 1
  • 4
10
votes
1 answer

How does delegate.Invoke work?

If I create a delegate in my code like : delegate void dostuff (string o); This generates a class that derives from System.MulticastDelegate which implements three methods - Invoke, BeginInvoke and EndInvoke. If I look at the compiled IL for Invoke…
Mongus Pong
  • 11,337
  • 9
  • 44
  • 72
10
votes
1 answer

Why is `std::invoke` not constexpr?

Shouldn't std::invoke be constexpr especially after constexpr lambdas in C++17? Are there any obstacles that will prevent this?
Vahagn
  • 4,670
  • 9
  • 43
  • 72
10
votes
7 answers

What's wrong with my cross-thread call in Windows Forms?

I encounter a problem with a Windows Forms application. A form must be displayed from another thread. So in the form class, I have the following code: private delegate void DisplayDialogCallback(); public void DisplayDialog() { if…
Arseni Mourzenko
  • 50,338
  • 35
  • 112
  • 199
9
votes
4 answers

Calling ASP.net Web Service from C# Application

I have a question. How can i invoke a web service and get the result from a C# desktop application. I am making a desktop app and I want it to be able to connect to my online ASP.net web services. How is this possible?
QAH
  • 4,200
  • 13
  • 44
  • 52
9
votes
3 answers

Debugging Invoked function in .NET

I call function in .NET using Reflection (Method.Invoke). If an error occurs inside this method and exception is raised, debugger doesn't show actual code but stops at Invoke() call. I can retrieve exception information from InnerException but this…
John
  • 2,295
  • 1
  • 20
  • 25
9
votes
1 answer

C# : this.Invoke((MethodInvoker)delegate

can somebody explain me the following code please : this.Invoke((MethodInvoker)delegate { lblNCK.Text = cncType; }); Here is where it comes from : string cncType; …
Peter
  • 103
  • 1
  • 1
  • 6