PSDataCollection<T>.Complete Method ()


Updated: April 27, 2016

Applies To: Windows PowerShell

Completes the process of adding content to the collection. This method must be called before the collection can be used to invoke a pipeline asynchronously. This method is introduced in Windows PowerShell 2.0.

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

public void Complete()

Subsequent inserts to the buffer will result in an InvalidOperationException.

This collection is typically used to create an input buffer that is used when invoking a pipeline of commands asynchronously.

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.

// Create the data to be sorted by the Sort-Object cmdlet.
PSDataCollection<int> input =
    new PSDataCollection<int>();

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

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

Return to top

Community Additions