Questions tagged [method-invocation]

135 questions
73
votes
9 answers

How to execute a method passed as parameter to function

I want to write my own function in JavaScript which takes a callback method as a parameter and executes it after the completion, I don't know how to invoke a method in my method which is passed as an argument. Like Reflection. example code function…
Muhammad Ummar
  • 3,541
  • 6
  • 40
  • 71
39
votes
5 answers

What is the difference between message-passing and method-invocation?

Is there a difference between message-passing and method-invocation, or can they be considered equivalent? This is probably specific to the language; many languages don't support message-passing (though all the ones I can think of support methods)…
Scrollbar
  • 791
  • 2
  • 7
  • 6
36
votes
7 answers

How to suspend a java thread for a small period of time, like 100 nanoseconds?

I know Thread.sleep() can make a java thread suspend for a while, like certain milliseconds and certain nanoseconds. But the problem is the invocation of this function also causes overhead. For example, if I want a thread to suspend for 100…
JackWM
  • 10,085
  • 22
  • 65
  • 92
20
votes
1 answer

Understanding the Dispatcher Queue

I think I need some help understanding the Dispatcher Queue. When new work arrives it gets added at the beginning of the dispatcher queue and when the Dispatcher wants to process a working item it gets removed from the beginning. In more general…
marc wellman
  • 5,808
  • 5
  • 32
  • 59
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
3 answers

Invoke method with an array parameter using reflection

I am attempting to write a method the executes a static method from another class by passing an array of strings as arguments to the method. Here's what I have: public static void executeStaticCommand(final String[] command, Class provider) { …
azz
  • 5,852
  • 3
  • 30
  • 58
12
votes
1 answer

Hit a bean method and redirect on a GET request

I'm using JSF 2 and PrimeFaces 2.1 on GlassFish. I have a page that is intended to allow people to perform an action after following a callback URL (e.g. as link embedded in email or as callback URL parameter of some external authentication or…
user550738
9
votes
2 answers

Ambiguous invocation caused by picking up two versions of System.Linq

I have the following code, which shows a squiggly red line under the lambda expression after .Any( because of an "ambiguous invocation" between System.Linq versions 3.5 and 4.0 - how do I force it to use a particular version? It compiles and runs…
greg84
  • 7,541
  • 3
  • 36
  • 45
9
votes
2 answers

perl constructor keyword 'new'

I am new to Perl and currently learning Perl object oriented and came across writing a constructor. It looks like when using new for the name of the subroutine the first parameter will be the package name. Must the constructor be using the keyword…
user2763829
  • 793
  • 3
  • 10
  • 20
8
votes
4 answers

How to invoke method on proxy(Spring AOP) by reflection in Java?

An interface: public interface Manager { Object read(Long id); } A class which implements this interface: @Transactional Public class ManagerImpl implements Manager { @Override public Object read(Long id) { // Implementation here …
Radon
  • 81
  • 1
  • 2
7
votes
2 answers

Example of multiple maximally specific methods that does not result in a compile-time error

I needed to dig into the specifics of method invocation in Java, and while reading the section Choosing the Most Specific Method in The Java Language Specification (Java SE 12 Edition), I found that (1) during invocation multiple methods can be…
johnnyodonnell
  • 1,838
  • 3
  • 16
  • 34
7
votes
3 answers

Dynamically Invoking Class Method Args

I am working on something where I need to be able to pass an indexed array of args to a method, much like how call_user_func_array works. I would use call_user_func_array but it is not an OOP approach, which is undesired, and it requires the method…
Mike Mackintosh
  • 13,917
  • 6
  • 60
  • 87
6
votes
2 answers

How to check if a subroutine was called with an object invocation method or not

You can invoke a subroutine as a method using the two syntaxes in the example below. But you can also invoke it not as an object. #==================================================== package Opa; sub opa{ $first= shift; $second= shift; …
5
votes
1 answer

What's the difference between $.attribute and self.attribute inside a class in Raku?

For example, in this class Foo both methods b and c return the same value: class Foo { method a { 42 } method b { $.a } method c { self.a } } my $foo = Foo.new; say $foo.a; #=> 42 say $foo.b; #=> 42 say $foo.c; #=> 42 I noticed…
uzluisf
  • 2,586
  • 1
  • 9
  • 27
5
votes
2 answers

How to map hash items to method parameters?

I have a method with a lengthy list of optional arguments, such as: def foo(foo = nil, bar = nil, baz = nil, qux = nil) # no-op end I thought that calling the method and passing a split hash as a parameter would map the hash items to parameters…
Filip Dupanović
  • 32,650
  • 13
  • 84
  • 114
1
2 3
8 9