private EventScheduler(ILogFile log) { _log = log; _repo = SchedulerRepo.NewSync(); _thr = ForeverThread.New(thread_loop, log); _hasNewTriger = new AutoResetEvent(false); }
private TcpAcceptor(int port, ILogFile log, AcceptedCallback acceptedCallback) { _log = log; _port = port; _acceptedCallback = acceptedCallback; _thr = ForeverThread.New(accepting_loop, log); _acceptor = new TcpListener(IPAddress.Any, _port); }
private IForeverThread[] create_threads(int count) { var threads = new IForeverThread[count]; for (int indx = 0; indx < count; indx++) { IForeverThread thr = null; thr = ForeverThread.New(() => thread_loop(thr), _log); // access to modified closure: use it to initialize thread loop threads[indx] = thr; } return threads; }
private void thread_loop(IForeverThread thr) { _log.Trace("IoThread is started"); while (true) { if (thr.StopRequestIsPosted()) break; bool mightHaveMoreWork = process_io(); if (mightHaveMoreWork) continue; Thread.Sleep(1); } _log.Trace("IoThread is done"); }