Adam Turner

Adam Turner

  • NA
  • 60
  • 0

Simple function to replace complicated Threads?

Jul 12 2007 4:48 PM
Hello, I'm trying to figure out a nice way to create a simple spawn() function for a simple game engine I'm working on to make it easier to use Threads. I'm unfamiliar with events but I'm thinking that may be what I need to get rid of the while statement below. I'd like any help I can get as I'm fairly new to programming in anything other than BYOND.

My code:

public delegate void function2call();

public void spawn(int time2sleep, function2call _function, ref bool isdone)

{

if (_function == null) return;

Thread gamethread = new Thread(new ThreadStart(_function));

sleep(time2sleep);

gamethread.Start();

while (!isdone) ;

gamethread.Join();

}


Answers (2)