예제 #1
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;
 }
예제 #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);
        }