Menu

Get-SasAsyncResult

Andreas Menrath
Synopsis
    Fetches the results or errors from an asynchronous task

Syntax
    Get-SasAsyncResult [-job] <Object> [<CommonParameters>]

Description
    This function allows you to write the results from the background job with the Cmdlets4Sas scriptblock to the powershell console.

Parameters
    -job <Object>
        The result from the Invoke-SasAsync commandlet with information about the job

        Required?                    true
        Position?                    1
        Default value                
        Accept pipeline input?       true (ByValue)
        Accept wildcard characters?  false

Notes
    The cmdlets first waits for the job to complete before any Results can be retrieved.
    When the job completes and a variable named $SasOutput exists in the background session then the results are copied to $job.SasOutput

Examples
    -------------------------- EXAMPLE 1 --------------------------
    C:\PS>$job  = Invoke-SasAsync $workspace $sb

    Wait-SasAsyncComplete $job
Get-SasAsyncResult $job

    -------------------------- EXAMPLE 2 --------------------------
    C:\PS>$ws = Connect-SasWorkspaceLocal

    $ScriptBlock = [scriptblock]{
                             $clone = Copy-SasWorkspace $SasInput; 
                             Invoke-SasCode $clone "data _null_; call sleep(10,1); run;";
                             # write data to console 
                             Read-SasData $clone "sashelp.class";
                             # save results in hashtable 
                             $SasOutput = @{};
                             $SasOutput["log"] = Read-SasLog $clone; 
                             $SasOutput["data"] = Read-SasData $clone "sashelp.class"; 
                             Disconnect-SasServer $clone; 
                            }
$job  = Invoke-SasAsync $ws $ScriptBlock
$job | Get-SasAsyncResult # writes to console

# use results from background job
$job.SasOutput["log"]
$job.SasOutput["data"]
Disconnect-SasServer $ws

Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.