Form doesn't always refresh


powershell 2.0, windows.forms

i have created windows form-based console perform variety of scripted operations against test environments.  during operation, sub-script uses custom function (below) write status information richtextbox.  on first attempt @ function, not show text until sub-script completed.  added $formmainbc.refresh() command, , seemed fix problem @ first.

the form does indeed show each update, if sit , stare @ it, waiting results.  if try switch different application multitasking while waiting, or if click on title bar of form move new location on screen, .refresh() command stops having visible effect, , form not repaint until after sub-script complete (which can hour later).  this has been tested, , near future used, on windows xp sp2 clients.

i have tried few different .select() , .focus() methods no avail.

what need .refresh() work in these circumstances?

function appendoutputtext
    {
    param ( [string]$outputtext = "", [string]$outputcolor = "black" )
    $outputtext = (get-date).tolongtimestring() + "  -  " + $outputtext
    $richmainoutput.focus()
    $richmainoutput.selectionstart = $richmainoutput.text.length
    $richmainoutput.selectioncolor = $outputcolor
    $richmainoutput.appendtext($outputtext)
    $formmainbc.refresh()
    }

(sorry cross-post.  had posted on official scripting guys forum last week, got no replies, i'm hoping find on forum.)

thanks,

tim c


behavior described didn’t appear on windows 7 system. suggest checking version of .net framework on windows xp. please try install latest version of .net framework test.

microsoft .net framework 4 (require windows xp sp3)
http://www.microsoft.com/downloads/en/details.aspx?familyid=9cfb2d51-5ff4-4491-b0e5-b386f32c0992&displaylang=en

thanks.


this posting provided "as is" no warranties, , confers no rights. please remember click "mark answer" on post helps you, , click "unmark answer" if marked post not answer question. can beneficial other community members reading thread.


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Edit Group Policy

Hyper-V VM not reaching OS 'Logon' screen

DNS question...