I'm trying to implement pooling function for datamovement operation in dynamic 365. I have a PowerShell script which is having a function called Test(pera1,pera2,pera3..) when we call this function it will take around 1hr+ time to complete the event. Now I have to call another task based on this Test() function result. If my condition is match then will call another task otherwise I have to put Start-Sleep -Seconds 3600 to complete the event.
function EnvOperationPooling($pera1, $pera2, $pera3)
{
// here API call code
// API result
if($apiResponse.DeploymentState-eq 'Inprogress')
{
Start-Sleep -Seconds 3600
EnvOperationPooling -proj1 $pera1 -proj2 $pera2 -proj2 $pera2
Write-Host "##vso[task.setvariable variable=DeploymentState;isOutput=true]$($apiResponse.DeploymentState)"
}
else
{
Write-Host "##vso[task.setvariable variable=DeploymentState;isOutput=true]$($apiResponse.DeploymentState)"
}
}
how i can make it recursive any suggetion to make above code better ..?