Example #1
0
        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();
        }
Example #2
0
 public static ThreadHelper StartNew(ThreadHelperAction action, bool whileTrue = true, int loopSleepInterval = 0)
 {
     return(new ThreadHelper(action, whileTrue, loopSleepInterval));
 }
Example #3
0
 public ThreadHelper(ThreadHelperAction action, bool whileTrue = true, int loopSleepInterval = 0)
 {
     this.Start(action, whileTrue, loopSleepInterval);
 }