Page 1 of 1

'Strange' behaviour of porgressbar

Posted: Thu Mar 08, 2012 8:12 pm
by Kenneth
Hi, I got the progressbar to work with the 'marquee' style. I use it when starting an external exe, which has an unknown execution time. This works fine, but when I insert an empty do-while function to repeat as long as the process run, then the progressbar doesn't show up, until AFTER the do-while has exited ? ------------------------------start-process $exefile -ArgumentList $arguments $buttonSplitInvoices.Enabled=0#Initialize the Progress Bar
$progressbar1.Style='Marquee'$progressbar1.MarqueeAnimationSpeed=40$progressbar1.Visible=1do {} while ((Get-Process "pcscmd" -ErrorAction SilentlyContinue) )-----------------------Can you help me whit this one ?Best regards,Kenneth

'Strange' behaviour of porgressbar

Posted: Fri Mar 09, 2012 5:31 am
by davidc
I recommend reading the following blog article: http://www.sapien.com/blog/2011/07/15/p ... ive-loops/ David

'Strange' behaviour of porgressbar

Posted: Fri Mar 09, 2012 5:47 am
by davidc
I also recommend getting the process object and checking if the process completed.$process = Start-Process -FilePath $processPath -PassThruif($process.HasExited){ #The Process
finished } you might also want to look at using a timer to check the process instead of looping. David