private WorkerThread AddWorkerThread()
        {
            lock (this.workerThreads)
            {
                var result = new WorkerThread(this.Process);

                this.workerThreads.Add(result);

                result.Stopped +=
                    (o, e) =>
                    {
                        var wt = o as WorkerThread;
                        lock (this.workerThreads)
                            this.workerThreads.Remove(wt);
                    };

                return result;
            }
        }
        private WorkerThread AddWorkerThread()
        {
            lock (workerThreads)
            {
                var result = new WorkerThread(Process);

                workerThreads.Add(result);

                result.Stopped += delegate(object sender, EventArgs e)
                                      {
                                          var wt = sender as WorkerThread;
                                          lock (workerThreads)
                                              workerThreads.Remove(wt);
                                      };

                return result;
            }
        }
 private WorkerThread AddWorkerThread()
 {
     lock (workers)
     {
         var newWorker = new WorkerThread(Process);
         workers.Add(newWorker);
         newWorker.Stopped +=
             ((sender, e) =>
             {
                 var worker = sender as WorkerThread;
                 lock (workers)
                 {
                     log.Info("Removing Worker");
                     workers.Remove(worker);
                 }
             });
         return newWorker;
     }
 }