1. Loops/Win32Lib Question

Hi all,

I tried sending this message to the mailing list, but I think there is something
wrong with my mail settings. Anyway…
When I use either }}}
<eucode>for</eucode>
{{{
 or }}}
<eucode>while</eucode>
{{{
loops in my
Win32Lib apps, the program freezes until the loop is done. Is there a way I can
perform my loop without freezing the app?
Thanks

new topic     » topic index » view message » categorize

2. Re: Loops/Win32Lib Question

Eucoder wrote:
> 
> Hi all,
> 
> I tried sending this message to the mailing list, but I think there is
> something wrong
> with my mail settings. Anyway…
> When I use either }}}
<eucode>for</eucode>
{{{
 or }}}
<eucode>while</eucode>
{{{
loops in my
> Win32Lib apps, the program freezes until the loop is done.
> Is there a way I can perform my loop without freezing the app?

If your loops are inside event handlers then I can understand what
is happening. Generally speaking, when one of your event handlers gets
control, Windows waits until you have finished and return from the event
handler. Most of the time this is okay because the event handler does
a tiny bit of work. However if you are doing some time consuming operation
in the handler it can be a problem.

The answer is to call the doEvents(0) routine from within your loop. 
When this is called, Windows gets control and processes any messages
waiting for action, then returns to your event handler. The tricky
part with this is that when doEvents() is running, other event handlers
might fire *before* you are ready for them.

For example, the user presses a button that kicks off your long running
loop. In the loop you call doEvents(), and while that runs, the user
presses the button again - thus causing its event handler to start (again)
...etc etc  

The way to deal with this is to disable the controls that you do NOT 
want the user to operate while your loop is running, then reenable
them just before returning from your event handler.

Hope this helps. If you want I can supply an example/demo program for you.

-- 
Derek Parnell
Melbourne, Australia

new topic     » goto parent     » topic index » view message » categorize

3. Re: Loops/Win32Lib Question

Ahhh I see Derek, thanks for clearing that up for me! If you can please send
that demo you mentioned, demos always help :)

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu