PSDataCollection Generic Class

A thread safe buffer that is used by Windows PowerShell host applications to provide input data when invoking a pipeline of commands asynchronously. This class is introduced in Windows PowerShell 2.0.

Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)

Dim instance As PSDataCollection(Of T)

generic<typename T>
public ref class PSDataCollection : IList<T>, ICollection<T>, 
	IEnumerable<T>, IList, ICollection, IEnumerable, 
	IDisposable, ISerializable



A type parameter that specifies the type of the data that is collected.

The following example shows how to add input data for the first command in the pipeline. In this case integers are added to the collection, and then those integers are sorted by the Sort-Object cmdlet.

PSDataCollection<int> input =
    new PSDataCollection<int>();

// Create an IAsyncResult object and call the
// BeginInvoke method to start invoking the 
// pipeline asynchronously.
IAsyncResult async = ps.BeginInvoke<int>(input);

// Using the PowerShell.Invoke method, run the 
// pipeline using the default runspace.
foreach (PSObject result in ps.EndInvoke(async))
} // End foreach.

When using this collection be sure to call the Complete method after adding data (as shown in the previous example). Windows PowerShell will continue to wait for more data until this call is made.

This collection is used for the input buffer for the following methods.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


Target Platforms

© 2015 Microsoft