private static Thread StartBackgroundThread(CmdletWorker worker)
 {
     var thread = new Thread(() => {
         try {
             worker.Execute();
         } catch (Exception ex) {
             worker.Queue.Add(new ErrorRecord(ex, "err01", ErrorCategory.NotSpecified, worker));
         }
         finally {
             worker.Queue.CompleteAdding();
         }
     }) { IsBackground = true };
     thread.Start();
     return thread;
 }
Beispiel #2
0
        private static Thread StartBackgroundThread(CmdletWorker worker)
        {
            var thread = new Thread(() => {
                try {
                    worker.Execute();
                } catch (Exception ex) {
                    worker.Queue.Add(new ErrorRecord(ex, "err01", ErrorCategory.NotSpecified, worker));
                }
                finally {
                    worker.Queue.CompleteAdding();
                }
            })
            {
                IsBackground = true
            };

            thread.Start();
            return(thread);
        }