2
Answers

Simple function to replace complicated Threads?

Adam Turner

Adam Turner

17y
2.2k
1
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)