private void HookupHostDataDelegates(ThreadJobHost host) { ThreadJobHostUI hostUI = host.UI as ThreadJobHostUI; System.Diagnostics.Debug.Assert(hostUI != null, "Host UI cannot be null."); hostUI.Output.DataAdded += (sender, dataAddedEventArgs) => { Collection <PSObject> output = hostUI.Output.ReadAll(); foreach (var item in output) { _output.Add(item); } }; hostUI.Error.DataAdded += (sender, dataAddedEventArgs) => { Collection <ErrorRecord> error = hostUI.Error.ReadAll(); foreach (var item in error) { Error.Add(item); } }; }
/// <summary> /// Constructor /// </summary> public ThreadJobHost() { _version = new Version(1, 0); _instanceId = Guid.NewGuid(); _ui = new ThreadJobHostUI(); }