Exemplo n.º 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;
 }
Exemplo n.º 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);
        }