public void Start() { using (_lock.WriterLock) { if (_queue.Find(v => v == this) != null) throw new AegisException(AegisResult.TimerIsRunning); _lastCallTime = _stopwatch.ElapsedMilliseconds - Interval; _queue.Add(this); // 동작중인 쓰레드가 없으면 생성 if (_timerThread == null) { _timerThread = new Thread(TimerThreadRunner); _timerThread.Start(); } } }
public SerialPortWatcher() { _pluggedPorts = new List<Tuple<SerialPort, object>>(); _unpluggedPorts = new List<Tuple<SerialPort, object>>(); _timer = new IntervalTimer(500, () => { Check(); }); _timer.Start(); }