interrupt sleep() or successive sleeps 
Author Message
 interrupt sleep() or successive sleeps

I have a dialog box used to transfer files across a net and implements
delays using a progress bar incremented in steps as a pause using the
::sleep() function. This allows the 3rd party host system to perform
processing of the transferred files.

I'd like to interrupt the while loop with the OnCancel notification in this
dialog. Is there an appropriate message and methodology to interrupt this
thread during the sleep count or catch the increment between sleep counts as
each increment occurs? So far, OnCancel has no effect during the transfer
process. There is an OnCancel test handler installed in the dialog.



Mon, 12 May 2003 03:00:00 GMT  
 interrupt sleep() or successive sleeps
Your problem is a bit technical.
The reason that "Cancel" button is not responding is that your application
is too busy.
You should not do all the operations when the other handlers are called.
Example:
OnOK()
{
    for (int i = 0; i < 1000; i++)
    {
        // do something
    }
Quote:
}

That will make your "THREAD" too busy.

Solution is to create another "Thread".
If you have never used them email me and I will help you to write a simple
one just to do the task.

I hope that is of some help to you.


Quote:
> I have a dialog box used to transfer files across a net and implements
> delays using a progress bar incremented in steps as a pause using the
> ::sleep() function. This allows the 3rd party host system to perform
> processing of the transferred files.

> I'd like to interrupt the while loop with the OnCancel notification in
this
> dialog. Is there an appropriate message and methodology to interrupt this
> thread during the sleep count or catch the increment between sleep counts
as
> each increment occurs? So far, OnCancel has no effect during the transfer
> process. There is an OnCancel test handler installed in the dialog.



Tue, 13 May 2003 03:00:00 GMT  
 interrupt sleep() or successive sleeps

Quote:

>I have a dialog box used to transfer files across a net and implements
>delays using a progress bar incremented in steps as a pause using the
>::sleep() function. This allows the 3rd party host system to perform
>processing of the transferred files.

>I'd like to interrupt the while loop with the OnCancel notification in this
>dialog. Is there an appropriate message and methodology to interrupt this
>thread during the sleep count or catch the increment between sleep counts as
>each increment occurs? So far, OnCancel has no effect during the transfer
>process. There is an OnCancel test handler installed in the dialog.

You could use CreateWaitable timer in conjunction with
MsgWaitForMultipleObjects. This lets you do the 'sleep' part for whatever
amount of time you want, and with the appropriate flags to
MsgWaitForMultipleObjects can be set to interrupt the wait when there are
messages to be processed, including clicks on the Cancel button.

However, the typical way to handle lengthy operations and delays whilst
keeping the user interface running is to use threads.

--

 http://www.andyh.uklinux.net/space - disk usage analysis tool



Tue, 13 May 2003 03:00:00 GMT  
 interrupt sleep() or successive sleeps
Actually the sleep() occurs within the while loop. Within the while loop
and before the sleep() I plan to test for a message (PeekMessage) set
for  a cancel message UINT ID from the dialog handle. This test will
occur on  each loop repeat.

Using SPY++ I plan shortly to test if the Cancel button is posting its
message but the dialog is too busy at its priority during said loop to
catch it.

If the button is not posting its message than I'll go into the threads
and priority setting investigation.

Quote:

> Your problem is a bit technical.
> The reason that "Cancel" button is not responding is that your application
> is too busy.
> You should not do all the operations when the other handlers are called.
> Example:
> OnOK()
> {
>     for (int i = 0; i < 1000; i++)
>     {
>         // do something
>     }
> }
> That will make your "THREAD" too busy.

> Solution is to create another "Thread".
> If you have never used them email me and I will help you to write a simple
> one just to do the task.

> I hope that is of some help to you.




Wed, 14 May 2003 03:30:04 GMT  
 interrupt sleep() or successive sleeps
I have just looked at these functions in the MSDN resource CDs and it
looks like this could be a way to trap to Cancel message.

This app may be installed on a workstation where near real-time control
(NT4) is constantly being applied by a number of other app modules. Some
copies of this app will be installed on 95/98 clerical workstations
networked to the same controllers so I must insure that it is portable.

Quote:

> You could use CreateWaitable timer in conjunction with
> MsgWaitForMultipleObjects. This lets you do the 'sleep' part for whatever
> amount of time you want, and with the appropriate flags to
> MsgWaitForMultipleObjects can be set to interrupt the wait when there are
> messages to be processed, including clicks on the Cancel button.

> However, the typical way to handle lengthy operations and delays whilst
> keeping the user interface running is to use threads.

> --

>  http://www.andyh.uklinux.net/space - disk usage analysis tool



Wed, 14 May 2003 03:35:41 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Q: How to set Sleep() between Sleep(0) and Sleep(1)?

2. To sleep or not to sleep, THAT is the question!

3. Wake Sleeping Thread?

4. sleep

5. Sleep (or Delay) without Timer

6. Restarting a sleeping thread

7. Sleep function

8. Thread.Sleep

9. Sleep after kill() self?

10. Sleep

11. sleeping with the enemy? J2EE and .NET

12. sleep

 

 
Powered by phpBB® Forum Software