private TimerWorkerThread AddWorkerThread() { lock (workerThreads) { var result = new TimerWorkerThread(() => { if (DateTime.Now - lastProcessTime < TimeSpan.FromMilliseconds(enforceProcessTime * 0.7)) { return; } BatchProcessMessage(); }, enforceProcessTime); workerThreads.Add(result); result.Stopped += delegate(object sender, EventArgs e) { var wt = sender as TimerWorkerThread; lock (workerThreads) { workerThreads.Remove(wt); } }; return(result); } }
private TimerWorkerThread AddWorkerThread() { lock (workerThreads) { var result = new TimerWorkerThread(() => { EnsureSubscribe(); CheckTopicServerHeartbeat(); }, this._heartbeatCheckMilliseconds); workerThreads.Add(result); result.Stopped += delegate(object sender, EventArgs e) { var wt = sender as TimerWorkerThread; lock (workerThreads) { workerThreads.Remove(wt); } }; return(result); } }