Killing batch process

Discussion in 'AutoCAD' started by pkirill, Feb 11, 2004.

  1. pkirill

    pkirill Guest

    We have a batch processor which is an EXE made with VB6. The only trouble
    with it is that when the user exits, the process stays running in the task
    manager. So by the end of the day there could be a dozen instances running.

    This is the code we use to exit the program:

    Private Sub cmdExit_Click()
    Unload Me
    End Sub

    I've also tried:

    Private Sub cmdExit_Click()
    Unload Me
    Set frmDLPlot = Nothing
    End
    End Sub

    Any ideas on how to get it to quit completely?

    Thanks!
     
    pkirill, Feb 11, 2004
    #1
  2. Any code in Form_QueryUnload?

    Or Form_Unload?

    Any Timers active when you try to unload the form?

    Any circular references?


    --
    Paul Marshall - Toot-OR

    When a wise man does not understand, he says: "I do not understand."
    The fool and the uncultured are ashamed of their ignorance.
    They remain silent when a question could bring them wisdom.
     
    Paul Marshall, Feb 11, 2004
    #2
  3. pkirill

    Norman Yuan Guest

    So called batch process is usually a loop (Do ... Until, While...wend,...).
    To interupt the loop process, you need put DoEvents statement in the middle
    of the loop. When the loop runs into DoEvents, it yields processing priority
    to Windows to excute pending event, such as user clicking a control.

    Common approach to stop a loop is as following code:

    Option Explicit
    Private mStop As Boolean 'Form level variable

    Private Sub cmdStop_Click
    mStop=True
    End Sub

    Private Sub cmdStartLoop_Click()

    mStop=False

    'Disable controls
    'Enable Stop button

    Do Until endOfProc
    'Do something....
    DoEvents 'Allow windows to check whether an event (user clicks
    the Stop button) pending
    If mStop Then Exit Do 'Get out of loop if cmdStop gas been
    clicked
    Loop

    'Enable controls
    'Disable Stop button

    End Sub

    DoEvents could have unexpected result: the event can only fires when
    DoEvents runs. If the processing takes long, impatient user may simply click
    somewhere on the form many times, or click a button you do not want it to
    run when the looping is in progress. So, make sure you disable all the
    controls except for "Stop" button once "Start" button is clicked, as above
    code shown. You may also want to cancel form closing when loop is on going,
    if user clicks "x" on the form.

    HTH
     
    Norman Yuan, Feb 11, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.