Export (0) Print
Expand All

PSDataCollection.Complete Method

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)

'Usage
Dim instance As PSDataCollection(Of T)

instance.Complete

public void Complete ()
public void Complete ()
public function Complete ()

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.

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.


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


Show:
© 2014 Microsoft