Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

win32::GUI - refresh ?

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
0
0
IL
Hi,

What is the normal method to refresh my GUI during other long operations running>

I do $main->Update() every time I enter the loop,but it does not make my gui windown movable still ...

Will appreciate any advise.
thanks

Long live king Moshiach !
 
Is the loop doing anything time-consuming for each loop? If so, only updating once per loop means that, if the loop takes 2 seconds to run, your window is only responsive for a fraction of a second every 2 seconds and is "frozen up" otherwise.

If it does something time-consuming, add more update calls inside the loop wherever possible.

Kirsle.net | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
thanks,that's what I have figured ou...
What about using thread to launch some background update to the main window?

Long live king Moshiach !
 
Probably not easy, unless the entire GUI is in the same thread. Sharing objects between threads is really difficult.

How about a thread to run the long process instead?

Kirsle.net | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Right,this is the first thing I have really tried out, and got messed with the way the thread was handling file redirections together with psexec usage,etc.
So gave it up eventualy...

This is the peace of code I was trying to thread unsuccessfully :

sub getMem {
$main->Update();
my $stationC = shift;
#print STDOUT "HERE3,$stationC\n";
# finding PPS memory
#system("psexec.exe \\\\$stationC -n 10 -u xxxx -p yyyy systeminfo 2>\"$TEMP\\$stationC.1a.err.txt\"|find \"Total Physical\" >>\"$TEMP\\$stationC.memory.txt\"");
system("wmic /NODE:\"$stationC\" /USER:xxxxx /PASSWORD:yyyyyy memlogical list full|find \"TotalPhysicalMemory\" >\"$TEMP\\$stationC.CS.txt\"");
#print STDOUT "HERE4\n";
$STATIONS->{$stationC} =1 unless ($product eq "710DFE");
if ($product eq "710DFE") {
#print STDOUT "HERE5\n";
my @stations = ("pps01","pps02","pps03","pps04","pps05","pps06","pps07","pps08");
for (@stations) {
$main->Update();
#print STDOUT "~~~$stationC.$_\n";
undef $result1;
my $result1 = `"$INSTPATH\\psexec.exe" \\\\$stationC -u xxxxx -p yyyy -n 5 ping -n 1 -w 200 $_ 2>\"$TEMP\\$stationC.$_.ping.txt\"|find "Lost = 0"`;
#Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
if ($result1 =~ /Lost = 0/) {
$main->Update();
print STDOUT "Checking memory on $stationC.$_ ...\n";
$STATIONS->{$stationC}{$_} =1;
open (FILE7,">$TEMP\\wmic.$_.bat");
print FILE7 "start /B cmd /c wmic /output:\"d:\\shared\\$stationC.$_.txt\" /NODE:\"$_\" memlogical list full";
close FILE7;
system("xcopy /y /q \"$TEMP\\wmic.$_.bat\" \\\\$stationC\\d\$\\shared\\ >NUL");
$main->Update();
system("\"$INSTPATH\\psexec.exe\" \\\\$stationC -u xxxx -p yyyy -n 5 \"\\\\$stationC\\d\$\\shared\\wmic.$_.bat\" 2>\"$TEMP\\$station.ping.txt\" >NUL");
select (undef,undef,undef,.20); #sleep .2 seconds
$main->Update();
system("xcopy /y /q \\\\$stationC\\d\$\\shared\\$stationC.$_.txt \"$TEMP\\\" >NUL");
}
unlink "$TEMP\\$stationC.$_.ping.txt";
}
}
}


Long live king Moshiach !
 
not a lot of answers to your questions but some (hopefully) helpful observations.
using qx instead of backticks/system can solve a lot of headaches with having to escape all the quotes.

Doing a system call to do a copy seems like more trouble than it's worth. Just use perls copy function.

I don't see you doing threads anywhere in there.. but I do know there are some examples on here that worked very simply for me when I wanted to testing threading on win32.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Thanks,

1.I use xcopy because it behaves better for me when copying between remote system folders.

2.this code was tested as a thread by me a week ago, but I gave up - got too many issues with system commands unable to redirect output.

Long live king Moshiach !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top