public void Start(ThreadHelperAction action, bool whileTrue = true, int loopSleepInterval = 0) { instances.Add(this); this.running = whileTrue; Thread th = new Thread(delegate() { do { action(this); if (loopSleepInterval > 0) { Thread.Sleep(loopSleepInterval); } }while (this.running); }); th.Start(); }
public static ThreadHelper StartNew(ThreadHelperAction action, bool whileTrue = true, int loopSleepInterval = 0) { return(new ThreadHelper(action, whileTrue, loopSleepInterval)); }
public ThreadHelper(ThreadHelperAction action, bool whileTrue = true, int loopSleepInterval = 0) { this.Start(action, whileTrue, loopSleepInterval); }