object calling outside method

  • Thread starter Thread starter Pujo Aji
  • Start date Start date
P

Pujo Aji

I have a problem with an object calling outside method:
Forexample in the main part I have an object and the object will do
something time independent, and after it is finished working it should
call outside function.

How can I do that?

public static void Main() {
mycls m = new mycls();
m.run();
}

public static void DoNext (){
//dosomething
}

class mycls {
public void run(){
//do something time independent
//Need to call DoNext !!!Problem
}
}

Pujo
 
I have a problem with an object calling outside method:
Forexample in the main part I have an object and the object will do
something time independent, and after it is finished working it should
call outside function.

How can I do that?

public static void Main() {
mycls m = new mycls();
m.run();
}

public static void DoNext (){
//dosomething
}

class mycls {
public void run(){
//do something time independent
//Need to call DoNext !!!Problem
}
}

The direct answer is that DoNext is a static method on some class although
your snippet doesn't show what class. So let's say the class is Class1,
then you call it as Class1.DoNext().

However you might want to consider using events or callbacks. Once mycls
has finished the processing of run it could raise a runFinished event.
 
Back
Top