From: Ludvig af K. <kli...@ho...> - 2001-02-11 19:05:23
|
I just read some about POE (Perl Object Environment - http://poe.perl.org), and it seems really interesting. I had the idea that by combining POE and Win32::GUI you could perhaps create a UI program that doesn't freeze whenever it's doing something time consuming. (e.g. sending/receiving data over a network) Some time ago I wrote a small program using Win32::GUI and LWP::UserAgent that downloaded a web page every X minutes and checked if it had been updated, and if it had the program popped up a window on the screen. The only problem was that it was impossible to interact with the program while it was downloading this (quite large) page from the (rather slow) server. The idea struck me that maybe rewriting the whole thing using POE might solve my troubles? As I said, I have no experience with POE, but if it could be successfully combined with Win32::GUI I would definitely look into it. So, can it be done? Has anyone with POE knowledge tried it? I think that's what I meant... -Ludde |
From: Reini U. <ru...@x-...> - 2001-02-11 19:42:42
|
If Win32::GUI would be thread-safe :) POE is for sure a very nice abstraction layer for process management. I would also recommend reading an ordinary win32 sdk book, the charles petzold "Programming Windows" probably. http://www.relisoft.com/win32/ if you borrow it from a library you'll get the cd, where the complete text is in chm! (4mb) This book would answer 80% if the questions here, btw. The very good perl cookbook has some good descriptions on process management, blocking, locks, threads, forks and alarms. There exists also a fulltext version in html. I don't fully understand this yet. but i think that your web monitor example is covered in the cookbook. Ludvig af Klinteberg schrieb: > I just read some about POE (Perl Object Environment - > http://poe.perl.org), and it seems really interesting. I had the idea > that by combining POE and Win32::GUI you could perhaps create a UI > program that doesn't freeze whenever it's doing something time > consuming. (e.g. sending/receiving data over a network) > > Some time ago I wrote a small program using Win32::GUI and > LWP::UserAgent that downloaded a web page every X minutes and checked if > it had been updated, and if it had the program popped up a window on the > screen. The only problem was that it was impossible to interact with the > program while it was downloading this (quite large) page from the > (rather slow) server. The idea struck me that maybe rewriting the whole > thing using POE might solve my troubles? As I said, I have no experience > with POE, but if it could be successfully combined with Win32::GUI I > would definitely look into it. So, can it be done? Has anyone with POE > knowledge tried it? -- Reini Urban http://xarch.tu-graz.ac.at/home/rurban/ |
From: Ludvig af K. <kli...@ho...> - 2001-02-12 19:29:24
|
I don't know much about the guts of Win32::GUI (or Win32 in general, or POE for that matter), but would a combination of POE and Win32::GUI be successful, or is Win32::GUI not stable enough yet? Or simply not constructed for that sort of thing? To me the possibilities seem great, but maybe I'm just following the hype, being too enthusiastic about POE. My monitoring example is, namely, just an example. It does by the way use quite a lot of HTTP specific stuff with cookies and redirects, so that's why I chose to implement the networking with a module instead of making it neatly non-blocking. -Ludde Reini Urban wrote: > > If Win32::GUI would be thread-safe :) > POE is for sure a very nice abstraction layer for process management. > > I would also recommend reading an ordinary win32 sdk book, the charles petzold > "Programming Windows" probably. http://www.relisoft.com/win32/ > if you borrow it from a library you'll get the cd, where the complete text > is in chm! (4mb) > This book would answer 80% if the questions here, btw. > > The very good perl cookbook has some good descriptions on process management, > blocking, locks, threads, forks and alarms. > There exists also a fulltext version in html. > I don't fully understand this yet. > > but i think that your web monitor example is covered in the cookbook. > > Ludvig af Klinteberg schrieb: > > I just read some about POE (Perl Object Environment - > > http://poe.perl.org), and it seems really interesting. I had the idea > > that by combining POE and Win32::GUI you could perhaps create a UI > > program that doesn't freeze whenever it's doing something time > > consuming. (e.g. sending/receiving data over a network) > > > > Some time ago I wrote a small program using Win32::GUI and > > LWP::UserAgent that downloaded a web page every X minutes and checked if > > it had been updated, and if it had the program popped up a window on the > > screen. The only problem was that it was impossible to interact with the > > program while it was downloading this (quite large) page from the > > (rather slow) server. The idea struck me that maybe rewriting the whole > > thing using POE might solve my troubles? As I said, I have no experience > > with POE, but if it could be successfully combined with Win32::GUI I > > would definitely look into it. So, can it be done? Has anyone with POE > > knowledge tried it? > -- > Reini Urban > http://xarch.tu-graz.ac.at/home/rurban/ > > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users |
From: christopher s. <chr...@ya...> - 2001-02-14 03:05:25
|
$|=1; use Win32::RASE; eval "use Time::HiRes qw(sleep)"; $hrasconn = (RasEnumConnections())[1]; $old_status = -1; while ( ($status, $status_text) = RasGetConnectStatus($hrasconn) ) { if ($status != $old_status) { print "$status: $status_text\n"; $old_status = $status; } sleep ($@ ? 1 : 0.01); } # error 6 - Invalid handle ($err = Win32::RASE::GetLastError) != 6 and die Win32::RASE::FormatMessage($err); exit; The above code goes into a while loop and constantly checks for the internet connection and prints connected or disconnected as appropriate Now my question is how do I use this loop in Win32 GUI suppose I use the above loop as it is control , will NOT be transferred to any other part of the program... I know that Win32::GUI::Dialog(); actually goes into an indefinite loop looking for keypresses etc How can I integrate the while loop also into theWin32::GUI::Dialog(); loop ? hope Im clear with my question if NOT I will elaborate Thanks chris www.perl-resume.com |
From: Aldo C. <da...@pe...> - 2001-02-14 10:12:13
|
christopher sagayam wrote: > $|=1; > use Win32::RASE; > eval "use Time::HiRes qw(sleep)"; > $hrasconn = (RasEnumConnections())[1]; > $old_status = -1; > while ( ($status, $status_text) = RasGetConnectStatus($hrasconn) ) { > if ($status != $old_status) { > print "$status: $status_text\n"; > $old_status = $status; > } > sleep ($@ ? 1 : 0.01); > } > # error 6 - Invalid handle > ($err = Win32::RASE::GetLastError) != 6 and die > Win32::RASE::FormatMessage($err); > exit; > > The above code goes into a while loop and constantly checks for > the internet connection and prints connected or disconnected as > appropriate > > Now my question is how do I use this loop in Win32 GUI well, it depends on the design of your application. basically, the Right Way is to use DoEvents. DoEvents is similar to Dialog, in the sense that it looks for keypresses, mouse clicks, etc. and fires the appropriate event(s). the big difference is that DoEvents does not loop, like Dialog, until it receives a termination message. instead, if there's nothing to process, DoEvents returns immediately. you can call DoEvents inside the loop like this: while ( ($status, $status_text) = RasGetConnectStatus($hrasconn) ) { if ($status != $old_status) { print "$status: $status_text\n"; $old_status = $status; } sleep ($@ ? 1 : 0.01); $MainWindow->DoEvents(); } this way your application can have a 'Stop' button that may, for example, break the loop (not *immediately* responsive, but better than nothing :-). the loop could be embedded in an event sub (for example, StartCheck_Click), or you can have no Win32::GUI::Dialog at all, so that the above loop is the real 'core' of the script. as I said, it depends on the design of your application. if this is not clear, please elaborate a bit more about the program you're trying to write. cheers, Aldo __END__ $_=q,just perl,,s, , another ,,s,$, hacker,,print; |
From: christopher s. <chr...@ya...> - 2001-02-14 12:53:15
|
Thanks aldo I will use DO event but in case there is a better solution do keep me posted Here is what Im trying to do I am trying to write a win32 gui perl client which when started will check whether the computer is connected to internet continuously indefinety in the meantime other actions should proceed also So based on your previous example actually there wont be a STOP button at all since this loop is going to be continuouly executed as along as the win32 gui script is running now the catch is during the time the loop is running I need to catch key presses , button presses , tab presses etc too and do it efficiently Thanks chris ----- Original Message ----- From: Aldo Calpini <da...@pe...> To: christopher sagayam <per...@li...> Sent: Wednesday, February 14, 2001 3:47 PM Subject: Re: [perl-win32-gui-users] looping in win32 GUI christopher sagayam wrote: > $|=1; > use Win32::RASE; > eval "use Time::HiRes qw(sleep)"; > $hrasconn = (RasEnumConnections())[1]; > $old_status = -1; > while ( ($status, $status_text) = RasGetConnectStatus($hrasconn) ) { > if ($status != $old_status) { > print "$status: $status_text\n"; > $old_status = $status; > } > sleep ($@ ? 1 : 0.01); > } > # error 6 - Invalid handle > ($err = Win32::RASE::GetLastError) != 6 and die > Win32::RASE::FormatMessage($err); > exit; > > The above code goes into a while loop and constantly checks for > the internet connection and prints connected or disconnected as > appropriate > > Now my question is how do I use this loop in Win32 GUI well, it depends on the design of your application. basically, the Right Way is to use DoEvents. DoEvents is similar to Dialog, in the sense that it looks for keypresses, mouse clicks, etc. and fires the appropriate event(s). the big difference is that DoEvents does not loop, like Dialog, until it receives a termination message. instead, if there's nothing to process, DoEvents returns immediately. you can call DoEvents inside the loop like this: while ( ($status, $status_text) = RasGetConnectStatus($hrasconn) ) { if ($status != $old_status) { print "$status: $status_text\n"; $old_status = $status; } sleep ($@ ? 1 : 0.01); $MainWindow->DoEvents(); } this way your application can have a 'Stop' button that may, for example, break the loop (not *immediately* responsive, but better than nothing :-). the loop could be embedded in an event sub (for example, StartCheck_Click), or you can have no Win32::GUI::Dialog at all, so that the above loop is the real 'core' of the script. as I said, it depends on the design of your application. if this is not clear, please elaborate a bit more about the program you're trying to write. cheers, Aldo __END__ $_=q,just perl,,s, , another ,,s,$, hacker,,print; _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users |
From: Aldo C. <da...@pe...> - 2001-02-14 13:24:23
|
christopher sagayam wrote: > Here is what Im trying to do > > I am trying to write a win32 gui perl client which when started > will check whether the computer is connected to internet > continuously indefinety in the meantime other actions should > proceed also > > So based on your previous example actually there wont be a STOP > button at all since this loop is going to be continuouly executed > as along as the win32 gui script is running > > now the catch is during the time the loop is running I need to > catch key presses , button presses , tab presses etc too and do > it efficiently I see. in this case, the best thing to do is to setup a Timer object with a small interval and do your connectivity test once inside its Timer event, no loop, no sleep :-) cheers, Aldo __END__ $_=q,just perl,,s, , another ,,s,$, hacker,,print; |
From: christopher s. <chr...@ya...> - 2001-02-14 15:51:23
|
Thanks aldo for all your info chris www.perl-resume.com ----- Original Message ----- From: Aldo Calpini <da...@pe...> To: christopher sagayam <per...@li...> Sent: Wednesday, February 14, 2001 6:59 PM Subject: Re: [perl-win32-gui-users] looping in win32 GUI christopher sagayam wrote: > Here is what Im trying to do > > I am trying to write a win32 gui perl client which when started > will check whether the computer is connected to internet > continuously indefinety in the meantime other actions should > proceed also > > So based on your previous example actually there wont be a STOP > button at all since this loop is going to be continuouly executed > as along as the win32 gui script is running > > now the catch is during the time the loop is running I need to > catch key presses , button presses , tab presses etc too and do > it efficiently I see. in this case, the best thing to do is to setup a Timer object with a small interval and do your connectivity test once inside its Timer event, no loop, no sleep :-) cheers, Aldo __END__ $_=q,just perl,,s, , another ,,s,$, hacker,,print; _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com |