Cancelling an action in progress 
Author Message
 Cancelling an action in progress

On a form, I have a button which starts a long process.  I would like to
give the user an option (via another button if possible) to cancel the long
operation.  What course of action can I take to ensure that the cancel click
is sensed and acted upon in the middle of the long process and what does
this entail in terms of the program?


Mon, 24 Nov 2003 22:02:01 GMT  
 Cancelling an action in progress
Hi Ed:

You could use a flag in the long process.

Form declarations:

Dim StopFlag as Integer

The Stop button:

Sub Command1_Click()
    StopFlag = 1
End Sub

In your process that takes a long time have it
check the 'StopFlag' flag to make sure that
its ok to keep going.

eg.

If StopFlag = 1 then
    StopFlag = 0
    Exit Sub
Endif

---
Good Luck!

Vincent Collura
(Inventor/Engineer)

http://www.CeBeans.com
Did you get your beans Today?


Quote:
> On a form, I have a button which starts a long process.  I would like to
> give the user an option (via another button if possible) to cancel the
long
> operation.  What course of action can I take to ensure that the cancel
click
> is sensed and acted upon in the middle of the long process and what does
> this entail in terms of the program?



Mon, 24 Nov 2003 22:18:26 GMT  
 Cancelling an action in progress
It doesn't appear that that click event is detected until the process (which
is triggered by a button on that same form) completes.

Thoughts?


Quote:
> Hi Ed:

> You could use a flag in the long process.

> Form declarations:

> Dim StopFlag as Integer

> The Stop button:

> Sub Command1_Click()
>     StopFlag = 1
> End Sub

> In your process that takes a long time have it
> check the 'StopFlag' flag to make sure that
> its ok to keep going.

> eg.

> If StopFlag = 1 then
>     StopFlag = 0
>     Exit Sub
> Endif

> ---
> Good Luck!

> Vincent Collura
> (Inventor/Engineer)

> http://www.CeBeans.com
> Did you get your beans Today?



> > On a form, I have a button which starts a long process.  I would like to
> > give the user an option (via another button if possible) to cancel the
> long
> > operation.  What course of action can I take to ensure that the cancel
> click
> > is sensed and acted upon in the middle of the long process and what does
> > this entail in terms of the program?



Sun, 30 Nov 2003 02:35:25 GMT  
 Cancelling an action in progress

Quote:
> It doesn't appear that that click event is detected until the process
(which
> is triggered by a button on that same form) completes.

> Thoughts?

Hi Ed:

I just checked and found out the "DoEvents" is not supported
in eVB.  If someone knows a API call that can do this then you
could use that. ( I don't know off hand)

Also if you are having this problem then one trick is to place
the timer on the form and use the Timer_Interval() event to
increment each step of the process.   You could go into the
code for the sub and have a place that it can break (start of
loop)

This will slow your program a little but you should not have
code that 'locks up'  the computer when doing a process.

Vincent Collura
(Inventor/Engineer)

http://www.CeBeans.com
Did you get your beans Today?



Sun, 30 Nov 2003 03:18:55 GMT  
 Cancelling an action in progress
I've been there before. Since there is no Addressof operator you can't
perform call backs. So Createthread API becomes useless to emVB.
That long process that anoys me is the Replication with SQL CE if IIS where
SQL CE Agent is waiting is down. Then my app keeps on running for ever to
perform replication. Timeout properties only take care of the part between
SQLCE Agent on IIS and SQL Server but between Pocket PC and IIS nothing is
coming. Even if not connected to the net at all it keeps on trying for ever.
We jsut got to learn C++ then we can perform callbacks and all other neat
things and our problems are solved.
Philipp


Quote:


> > It doesn't appear that that click event is detected until the process
> (which
> > is triggered by a button on that same form) completes.

> > Thoughts?

> Hi Ed:

> I just checked and found out the "DoEvents" is not supported
> in eVB.  If someone knows a API call that can do this then you
> could use that. ( I don't know off hand)

> Also if you are having this problem then one trick is to place
> the timer on the form and use the Timer_Interval() event to
> increment each step of the process.   You could go into the
> code for the sub and have a place that it can break (start of
> loop)

> This will slow your program a little but you should not have
> code that 'locks up'  the computer when doing a process.

> Vincent Collura
> (Inventor/Engineer)

> http://www.CeBeans.com
> Did you get your beans Today?



Sun, 30 Nov 2003 21:58:55 GMT  
 Cancelling an action in progress
Greets,

    DoEvents() can be simulated by using a PeekMessage() loop and using
TranslateMessage() and DispatchMessage() within the loop.  The only problem
one must be careful for is reentrancy, since this type of behavior in a
handler could indeed dispatch another message that calls the handler once
again.

Regards,

Joe


Quote:


> > It doesn't appear that that click event is detected until the process
> (which
> > is triggered by a button on that same form) completes.

> > Thoughts?

> Hi Ed:

> I just checked and found out the "DoEvents" is not supported
> in eVB.  If someone knows a API call that can do this then you
> could use that. ( I don't know off hand)

> Also if you are having this problem then one trick is to place
> the timer on the form and use the Timer_Interval() event to
> increment each step of the process.   You could go into the
> code for the sub and have a place that it can break (start of
> loop)

> This will slow your program a little but you should not have
> code that 'locks up'  the computer when doing a process.

> Vincent Collura
> (Inventor/Engineer)

> http://www.CeBeans.com
> Did you get your beans Today?



Mon, 01 Dec 2003 00:40:30 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. prevent OpenReport action dialog to appear when cancelling print job

2. Cancelling an action from a MenuItem

3. Cancelling actions / procedures in VB4.0

4. Cancelling an Addnew action with a dbAutoincrfield issue

5. Cancelling actions / procedures in VB4.0

6. HELP: cancelling move with validate event action = 0

7. Moving a progress bar while executing a continous action

8. Adding a new Action to the ACTION LIST

9. File Loading Progress Form with Progress Bar

10. Progress or something to let user know script is in progress (WSH, not HTML)

11. How do I display a progress bar showing progress for database replication

12. How do I display a progress bar showing progress for database replication

 

 
Powered by phpBB® Forum Software