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; }
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); }