method-call

Executing a function by name, passing an object as a parameter

Hi, Here's the problem - I know function by name (and that function has already been loaded form an external script), but I don't have an actual function object avail for me to call. Normally I would call eval(function_name + "(arg1, arg2)"), but in my case I need to pass an object to it, not a string. Simple example: var div = docume...

Calling method from child class

Hello, In Silverlight / C#, I have class Main, which creates an instance of Child, Child _child = new Child(...) Now, in Child class I need to call a method from Main class. What should be the best way to do this ? Events? ...

How to explain method calls?

Hi, let's consider a small method: int MyFunction(string foo, int bar) { ... } and some calls: MyFunction("",0) int x = MyFunction(foo1,bar1) How would you explain this to a non-technical persons? Has anybody a nice metaphor? I tried to explain method calling (or function application) several times, but I failed. Seems I can't ...

how to call the method in thread with aruguments and return some value

i like to call the method in thread with aruguments and return some value here example class Program { static void Main() { Thread FirstThread = new Thread(new ThreadStart(Fun1)); Thread SecondThread = new Thread(new ThreadStart(Fun2)); FirstThread.Start(); SecondThread...

What is the best way to call a method right AFTER a form loads?

I have a C# windows forms application. The way I currently have it set up, when Form1_Load() runs it checks for recovered unsaved data and if it finds some it prompts the user if they want to open that data. When the program runs it works alright but the message box is shown right away and the main program form (Form1) does not show unti...

The fastest way to call a method

Reading this article I found several ways to call a method. Method to call: public static void SendData(string value) { } Calls: delegate void MyDelegate(string value); //Slow method - NOT RECOMMENDED IN PRODUCTION! SendData("Update"); // Fast method - STRONGLY RECOMMENDED FOR PRODUCTION! MyDelegate d = new MyDelegate(Send...

"Iterating" through methods

Hi. Let's say I've got a Java object that's got among others the following methods: public String getField1(); public String getField2(); public String getField3(); public String getField4(); public String getField5(); Is there a way to iterate through these methods and call 'em like the following code? String fields = ""; for(int i...

Java compiler optimization for repeated method calls?

Does the java compiler (the default javac that comes in JDK1.6.0_21) optimize code to prevent the same method from being called with the same arguments over and over? If I wrote this code: public class FooBar { public static void main(String[] args) { foo(bar); foo(bar); foo(bar); } } Would the method f...

How do I call a method of a Java instance from JavaScript?

I'm using the Mozilla Rhino JavaScript emulator. It allows me to add Java methods to a context and then call them as if they were JavaScript functions. But I can't get it to work except when I use a static method. The problem is this part of the documentation: If the method is not static, the Java 'this' value will correspond to the...

How to see from where a public method is called in Eclipse using Java?

I am working on a Java project in Eclipse. Sometimes when I do refactoring I would like to see from what other classes a public method is called. There is a primitive way to do this, that I am using now. I can comment out the method and see in what classes there is an error in Eclipse. Is there any better way to do this in Eclipse? E.g....

How do I update the JavaScript this-pointer inside an object to point to another object?

hi guys, I'm having some trouble with JavaScript and the passing of a function as parameter of another function. let's say we are inside a class and do something like that: this.get('target').update(this.onSuccess, this.onFail); 'target' is a JavaScript-object that has a method called update() I'm calling this method and pass tow me...

Calling a method when UIWebView scrolls...

I have a UIWebView that contains a lot of text content. I need to be able to get the location of the UIWebView every time it moves. I am using this code to get the point: pageYOffset = [[webView stringByEvaluatingJavaScriptFromString:@"window.pageYOffset"] intValue]; now I just need to make it so that this variables value is updated e...