Results 1 to 4 of 4

Thread: [RESOLVED] Abort code execution using a cancel button

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    The Netherlands
    Posts
    34

    Resolved [RESOLVED] Abort code execution using a cancel button

    Hi everyone,

    I've been trying to find this on google or on this forum but couldn't find it.

    I have a long procedure to execute. I would like the user to be able to abort the process by clicking a cancel button. However normally after the execution is started no user input is allowed untill the complete procedure is completed. How do i enable userinput (clicking a cancel button) during execution and have the system abort execution?

    Any help (in code or tutorials) is appreciated.

    Thanks
    Last edited by irenicus; Mar 22nd, 2006 at 06:46 AM.

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Abort code execution using a cancel button

    You can put DoEvents in that long procedure. This will let the User do something else in the application. But mind you the performance will be slow when you put DoEvents. Declare a boolean variable and set it true on the click of the cancel button. And in your procedure check for that variable, if it is true stop the process.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    The Netherlands
    Posts
    34

    Re: Abort code execution using a cancel button

    Some additional information may come in handy:

    I called this a procedure but actually it's a long process that included multiple procedures and functions (around 50+). I will try to put DoEvents on the most critical positions in the process to allow for cancelation of the procedure and proper abortion of the process.

    I will let you know if it worked.

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    The Netherlands
    Posts
    34

    Re: Abort code execution using a cancel button

    Thanks, it works very well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width