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
6
votes
1 answer

Checking whether an `object[] args` satisfies a Delegate instance?

I have the following method signature: public static void InvokeInFuture(Delegate method, params object[] args) { // ... } The delegate and the arguments are saved to a collection for future invoking. Is there any way i can check whether the…
DxCK
  • 4,402
  • 7
  • 50
  • 89
6
votes
1 answer

ProcessStartInfo and Process in PowerShell - Authentication Error

I have code that uses ProcessStartInfo and Process to invoke another script, and to return the output of that script. Unfortunately, I am getting errors, and I am unsure how to troubleshoot them. #script1.ps1 $abc = $args $startInfo =…
Glowie
  • 2,271
  • 21
  • 60
  • 104
6
votes
4 answers

How to get the methodname from a known method?

Is it possible to get the name of another method in the same class but without using a manually written string? class MyClass { private void doThis() { // Wanted something like this print(otherMethod.name.ToString()); } …
Malvin
  • 859
  • 2
  • 11
  • 19
6
votes
5 answers

PHP Callable Object as Object Member

I have a class Logger which, among other things has a method Log. As Log is the most common use of the Logger instance, I have wired __invoke to call Log Another class, "Site" contains a member "Log", an instance of Logger. Why would this work: …
James Maroney
  • 3,136
  • 3
  • 24
  • 27
6
votes
6 answers

C# Threading using invoke, freezing the form

I'm trying to use threads and prevent the program from freezing while the thread is busy. It should show the progress (writing of 0's / 1's) and not just show the result after its done, freezing the form in the meanwhile. In the current program I'm…
Random IT Guy
  • 625
  • 1
  • 8
  • 16
6
votes
3 answers

C# cast a class to an Interface List

I'm trying to load some .dll files dynamically. The Files are Plugins (self-written for now) which have at least one class that implements MyInterface. For each file I'm doing the following: Dictionary _myList; //…
Phil
  • 130
  • 6
6
votes
3 answers

Pass a bool Foo(params[]) as method Argument

There are times that a method needs to be run several times until it validates. In my case there are expressions like bar.Name.Equals("John Doe") which I want to run and run until this expression validates. Something like: bool succeeded =…
Odys
  • 8,951
  • 10
  • 69
  • 111
5
votes
1 answer

how to call (invoke) onChildClick method of expandable listview?

I'm working on expandable list view. I've set onClickHandler on imageview of the child row, because inline clicklistners not working in this case. But I need int groupPosition and childPosition for some processing in my program. And these are…
Never Quit
  • 2,072
  • 1
  • 21
  • 44
5
votes
3 answers

Using NSProxy and forwardInvocation:

I would like to code a proxy that forwards method invocations to another object over TCP without NSConnection and NSDistanceObject stuff. What I want is my own protocol. The problem is that subclassing NSProxy and overriding forwardInvocation: is…
cocoafan
  • 4,884
  • 4
  • 37
  • 45
5
votes
3 answers

Why isn't Invoke via Delegate built into .NET

I understand that .NET is multi-threaded and that is a good thing, but I continually run into issues when I have a background worker for example that is updating some control on my form and I have to do: Private Sub…
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143
5
votes
2 answers

I want to print hi GrandFather;but it seems to print hi father

I want to print hi GrandFather But it seems to print hi father. And I am not understand how to diff the use between findSpecial and findVirtual I want someone can help me. Thank you class GrandFather{ void thinking(){ …
Chronos
  • 69
  • 3
5
votes
3 answers

What's the use of Invoke() in .net?

I found this code: this.Invoke(new EventHandler(EventGetSum)); Is this not the same as writing: EventGetSum(); What's the use of this?
Gold
  • 60,526
  • 100
  • 215
  • 315
5
votes
2 answers

Speeding up realtime Gui updates from a thread

This is a technique I've used for years to receive network data and use it in my GUI (dialog, form etc). public delegate void mydelegate(Byte[] message); public ReceiveEngineCS(String LocalIpIn, String ReceiveFromIp, mydelegate d) { …
Sleff
  • 89
  • 1
  • 7
5
votes
2 answers

Where should TreeView's Invoke method between two WinForms be handled?

I have two WinForms (Setting and frmMain). I have a TreeView in Setting's form and I want to call its FillTree method in the second form frmMain. I'm using the TreeView.Invoke for the threading purposes. Here is my code for TreeView filling data in…
user1773603
5
votes
5 answers

Winforms multithreading: Is creating a new delegate each time when invoking a method on the UI thread needed?

I want to invoke a method that manipulates a control on the UI thread. My code works and I want to optimize. I am referring to this resource on MSDN. According to there, we should do public delegate void myDelegate(int anInteger, string…
Marcel
  • 15,039
  • 20
  • 92
  • 150