From: <Kev...@al...> - 2002-10-17 15:52:59
Attachments:
fork.zip
|
Michael, I did quite a bit of experimenting with Fork and Win32::GUI a while ago. The main problem I hit was perl crashed when the window closed. I guessed there was some sort of memory management problem but couldn't figure out what. Eventually I gave up and used a doevents approach (I did try Tk but this isn't thread safe so crashes as soon as a fork occurs). If you're still interested in trying fork I've attached one of the scripts I was playing with. The fork routines are in a seperate module PipeFork.pm which I've also included. The parent handles the windows events, tells the child what events have occured and the child performs the appropriate actions (in this case calculating the size of subdirectories). I'll be interested to hear if you have more success than I did. Cheers, Kev. (See attached file: fork.zip) |---------+------------------------------------------------> | | "Michael Alaly" <mi...@fl...> | | | Sent by: | | | per...@li...ur| | | ceforge.net | | | | | | | | | 17/10/2002 15:37 | | | | |---------+------------------------------------------------> >----------------------------------------------------------------------------------------------| | | | To: <per...@li...> | | cc: | | Subject: [perl-win32-gui-users] LWP + Fork + Win32::GUI | >----------------------------------------------------------------------------------------------| Hello, I don't know how to continue a thread that started before I joined the list so I apologize in advance: "Is possible to modify LWP module in order to avoid a frozen window ?" I have spent the morning searching for some solutions involving LWP, Fork and Win32::GUI. I saw in the archives for this list that some of this has been discussed before and that one question I can answer had been asked by "Guillem Cunillera Wefers <vacarisses@es...>". Guillem if you are still interested in how to do this, you will want to use the callback function in LWP and call the DoEvents() inside that callback. You can set the number of bytes to read before calling the function. This should allow you to use DoEvents liberally within any call to LWP. I have some questions regarding your program if you could contact me off-list I would apprecaite it. I am new to Win32::GUI and forking and am trying to do something very similar to what it looked like you were trying to do. I am attempting to take a list of links from a ListView and send them each to a child for download. I am running into lots of problems with fork and page faults that I can't seem to solve. Cheers, Michael ------------------------------------------------------- This sf.net email is sponsored by: viaVerio will pay you up to $1,000 for every account that you consolidate with us. http://ad.doubleclick.net/clk;4749864;7604308;v? http://www.viaverio.com/consolidator/osdn.cfm _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users |
From: Alex L. <sim...@ya...> - 2002-10-17 19:54:45
|
Did you try using: Win32::Shell::Execute instead of fork. I had a lot of problem with fork under win32 in the past and finally found this little gem. Alex ;) ===== ************************** ***** END OF MESSAGE ***** __________________________________________________ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com |
From: Johan L. <jo...@ba...> - 2002-10-17 20:24:35
|
Weird effect. Using 0.0.558, I call Win32::GUI::DoEvents() manually from a main loop . I have a popup-menu on a NotifyIcon, nothing else. This is the weird thing. When I select something in the menu, the event handler gets called twice. The main loop is basically: IO::Select->select($readable, $writeable, undef, 0.1); DoEvents(); * I tried to lower the timeout value to 0.05, same thing. * Can I discard the remaining event queue if nothing else works? * Replace my DoEvents-loop with Win32::GUI::Dialog() and it works fine. Any ideas? /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos jo...@ba... Latest bookmark: "Perl memory management - Jan Dubois - Re lookin..." http://aspn.activestate.com/ASPN/Mail/Message/895049 dmoz (1 of 8): /Computers/Programming/Languages/Ruby/ 33 |
From: Morbus I. <mo...@di...> - 2002-10-17 20:51:55
|
>Using 0.0.558, I call Win32::GUI::DoEvents() manually from a main loop . I I've noticed it as well. I just check to see if I've $already_called: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/amphetadesk/AmphetaDesk/ lib/AmphetaDesk/OS/Windows.pm?rev=1.7&content-type=text/vnd.viewcvs-markup -- Morbus Iff ( i'm the droid you're looking for ) Culture: http://www.disobey.com/ and http://www.gamegrene.com/ Please Me: http://www.amazon.com/exec/obidos/wishlist/25USVJDH68554 icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus |
From: Johan L. <jo...@ba...> - 2002-10-17 22:26:56
|
At 16:51 2002-10-17 -0400, Morbus Iff wrote: > >Using 0.0.558, I call Win32::GUI::DoEvents() manually from a main loop . I > >I've noticed it as well. I just check to see if I've $already_called: > > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/amphetadesk/AmphetaDesk/ > lib/AmphetaDesk/OS/Windows.pm?rev=1.7&content-type=text/vnd.viewcvs-markup Great, thanks! It's too bad it's needed but it works, so long as the two events come sufficiently close to each other so the sub doesn't have time to exit. sub ::mnu_tray_config_open_Click { return(1) if(!$workaround_handler_semaphore++); system("start $program_editor $file_user_prefs"); $workaround_handler_semaphore = 0; return(1); } /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos jo...@ba... Latest bookmark: "Atari Icon Library" http://aicq.atari-users.net/iconz/ dmoz (1 of 2): ...Computers/Software/Desktop_Customization/Icons/ 137 |
From: Johan L. <jo...@ba...> - 2002-10-17 22:38:47
|
At 00:25 2002-10-18 +0200, Johan Lindstrom wrote: sub ::mnu_tray_config_open_Click { > return(1) if(!$workaround_handler_semaphore++); Hrmm... Thinko. Remove the ! for a more solid solution :/ /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos jo...@ba... Latest bookmark: "Atari Icon Library" http://aicq.atari-users.net/iconz/ dmoz (1 of 2): ...Computers/Software/Desktop_Customization/Icons/ 137 |
From: Johan L. <jo...@ba...> - 2002-10-21 20:20:24
|
At 22:23 2002-10-17 +0200, Johan Lindstrom wrote: >Using 0.0.558, I call Win32::GUI::DoEvents() manually from a main loop . I >have a popup-menu on a NotifyIcon, nothing else. > >This is the weird thing. When I select something in the menu, the event >handler gets called twice. Ok. The same thing goes for cursor movement events within e.g. a RichEdit or a TextField control. Pressing the right arrow to move the cursor one step will cause it to go two steps. Pressing the down arrow to move down one row will jump two rows down. Pressing e.g. Tab to move to the next control works fine. This is isolated to DoEvents. Using Win32::GUI::Dialog(), everything works fine. Even the tightest possible DoEvents loop: Win32::GUI::DoEvents() while(1); will cause this problem, so it's not that I have too much time away from the GUI. Win32::GUI 0.0.558. /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos jo...@ba... Latest bookmark: "XEmacs XEmacs and Supporting Libraries and Prog..." http://xemacs.org/Download/win32/ dmoz: /Computers/Open_Source/Software/Editors/ 98 |
From: Johan L. <jo...@ba...> - 2002-10-21 22:50:03
|
At 22:21 2002-10-21 +0200, Johan Lindstrom wrote: >>Using 0.0.558, I call Win32::GUI::DoEvents() manually from a main loop . >>I have a popup-menu on a NotifyIcon, nothing else. >> >>This is the weird thing. When I select something in the menu, the event >>handler gets called twice. > >Ok. The same thing goes for cursor movement events within e.g. a RichEdit >or a TextField control. Pressing the right arrow to move the cursor one >step will cause it to Ok. This is as kluge if I ever saw one. But it works (I guess). This is my (simplified) idle sub, which I call as often as possible: use constant WM_APP => 0x8000; #From winuser.h (Visual Studio) use constant WM_EXITLOOP => WM_APP + 1; #From GUI.xs sub idle { my ($win) = tglApp($tglWindow); if($win->PeekMessage()) { $win->PostMessage(WM_EXITLOOP, 0, 0) for (0..1); Win32::GUI::Dialog(); } Win32::GUI::DoEvents() while($win->PeekMessage()); return(1); } So it works like this. I want to use the DoEvents for my tray icon. But I need the Dialog() call for the window, otherwise some keyboard events are doubled. So if there are messages waiting on the window, I post two WM_EXITLOOP (one isn't enough, maybe I'll post more just to be sure) to the end of the message queue. That way I can do the Dialog() call and still get back control. Then I empty the event queue with DoEvents() so it's clear for the next run, and the tray icon gets processed as well. (Hmmm... maybe I could do the same with the tray icon, that way the menu events may work as indented as well...) There's probably a good reason why I shouldn't do any of this. /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos jo...@ba... Latest bookmark: "XEmacs XEmacs and Supporting Libraries and Prog..." http://xemacs.org/Download/win32/ dmoz: /Computers/Open_Source/Software/Editors/ 98 |
From: <ma...@mm...> - 2002-10-17 22:51:56
|
i was under the impression that forking didn't work at all under windows.....some problem with svtypes(? ). perl 5.8.0 threads and win32::gui seem to work wonderfully tho. = =20 Johan Lindstrom <jo...@ba...> = =20 Sent by: To: = =20 per...@li...urc <perl= -wi...@li...> =20 eforge.net cc: = =20 Subje= ct: Re: [perl-win32-gui-users] LWP + =20 Fork = + Win32::GUI =20 18/10/02 02:03 AM = =20 = =20 = =20 At 10:37 2002-10-17 -0400, Michael Alaly wrote: >off-list I would apprecaite it. I am new to Win32::GUI and forking and= am >trying to do something very similar to what it looked like you were tr= ying >to do. I am attempting to take a list of links from a ListView and sen= d them >each to a child for download. I am running into lots of problems with = fork >and page faults that I can't seem to solve. fork under Win32 is emulated using IThreads (the only use of IThreads i= n 5.6.1). They seem to work fine using pure Perl, but XS code is more difficult (Win32::GUI is XS, and it also allocates Windows resources). = Any solution with fork + Perl 5.6.1 should be considered unstable unless te= sted a _lot_. And I still woulnd't trust it :) IThreads in Perl 5.8 is supposed to be a lot better. So when ActiveStat= e releases a 5.8 distro, maybe we can make use for it. I think one of the new things is that variables aren't shared between threads unless you say so. And that, I hope, may solve the entire probl= em with non-reentrant XS code and such. That would be _real_ nice! /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindstr=F6m Sourcerer @ Boss Casinos jo...@ba... Latest bookmark: "Perl memory management - Jan Dubois - Re lookin..." http://aspn.activestate.com/ASPN/Mail/Message/895049 dmoz (1 of 8): /Computers/Programming/Languages/Ruby/ 33 ------------------------------------------------------- This sf.net email is sponsored by: viaVerio will pay you up to $1,000 for every account that you consolidate with us. http://ad.doubleclick.net/clk;4749864;7604308;v? http://www.viaverio.com/consolidator/osdn.cfm _______________________________________________ Perl-Win32-GUI-Users mailing list Per...@li... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users = |
From: Michael A. <mi...@fl...> - 2002-10-18 22:08:52
|
Something like this should do the trick: my $req = new HTTP::Request GET => $url; my $res = $ua->request($req, sub {Win32::GUI::DoEvents();}, 1024); That will make your request and update the window every 1024 bytes read from the response. That particular snippet obviously does nothing with the response but you can do quite a bit of useful things here. This worked really well with the download application I am trying to make. The only hang-up is that if your request times out or blocks for any number of other reasons (DNS failures don't return within the UserAgent timeout, they can take up to a minute to resolve) the screen will freeze until you get the error response code. Check out LWP's documentation for more details there's some useful variables and methods you can use within the sub if I remember correctly. Michael > > Do you have a code example how to call LWP with the callback > function? > > Thanks a lot, > Felix Gaehler |