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)

'Usage
Dim instance As PSDataCollection(Of T)

'Declaration
<SerializableAttribute> _
<DefaultMemberAttribute("Item")> _
Public Class PSDataCollection(Of T)
	Implements IList(Of T), ICollection(Of T), _
	IEnumerable(Of T), IList, ICollection, _
	IEnumerable, IDisposable, ISerializable

GenericParameters

T

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>();
input.Add(5);
input.Add(3);
input.Add(2);
input.Complete();

// 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))
{
    Console.WriteLine(result);
} // 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.


System.Object
  System.Management.Automation.PSDataCollection

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

Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.
Show:
© 2014 Microsoft