PowerShell wait for function call to complete -
i calling series of powershell functions master script (each function test). specify tests in xml file , want them run in order.
the functions call organized in powershell module files (.psm1). master script calls import-module needed , calls function via this...
$newresults = & "$runfunction" @args
or this...
$newresults = invoke-expression $runfunctionwithargs
i have gotten both work fine , xml file parsing invokes these commands in correct order.
problem: tests apparently launched asynchronously first test launch not invoked , complete before second test invoked.
note, tests functions in powershell module , not commands not think start-process work (but please tell me if know how make work).
more details: take add code, each function call create hashtable 1 or more "testresult" objects. "testresult" has things success codes , timestamp. each test things take different amounts of time, synchronous. expect timestamps same order called each test, since first thing each test timestamp should not depend on test does. when run in ise, goes in order. when run in command window, timestamps not match expected order.
workaround: working theory still powershell somehow parallelizing calls. can consistent results making invocation of each call dependent on results of previous call. dummy check because know test true, powershell doesn't know that
if ($newresults.count -ne [long]::maxvalue) { $newresults = & "$runfunction" @args }
powershell thinks needs know if previous call count not maxvalue.
Comments
Post a Comment