Multiple calls of messages, Flash


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Multiple calls of messages, Flash

  1. #1
    Jacek Bator Guest

    Multiple calls of messages, Flash


    I'am working with vb6 and I have problem.
    I have form and buttons, when i press the button some action is called and
    it's beening executed,
    when i press this button another time, another action is called and executed
    even if previous one didn't
    finished. Is there any way to solve this problem not at code level (semaphores
    etc.), because for example
    with flash OCX errors ocures inside of this control, when i disable it(OCX)everything
    is ok, but after enabling it again i sometimes
    get calls of some mesages.

    Best Regards
    Jacek Bator
    jbator@man.poznan.pl

  2. #2
    Colin McGuigan Guest

    Re: Multiple calls of messages, Flash

    Jacek Bator wrote in message <3906ff58$1@news.devx.com>...
    >
    >I'am working with vb6 and I have problem.
    >I have form and buttons, when i press the button some action is called and
    >it's beening executed,
    >when i press this button another time, another action is called and

    executed
    >even if previous one didn't
    >finished. Is there any way to solve this problem not at code level

    (semaphores
    >etc.), because for example
    >with flash OCX errors ocures inside of this control, when i disable

    it(OCX)everything
    >is ok, but after enabling it again i sometimes
    >get calls of some mesages.
    >
    >Best Regards
    >Jacek Bator
    >jbator@man.poznan.pl


    Disable the button and set the mouse pointer to an hourglass. When it
    finishes, re-enable the button, and set the mouse pointer back to normal.
    You can also use a module level Boolean as a sort of semaphore; the
    procedure can check the value of the Boolean. If it's True, then the
    procedure does nothing and exits. Otherwise, it sets it to True, does its
    work, and then, when done, sets it to False. This would prevent the code
    from running more than once at a time.

    --
    Colin McGuigan




  3. #3
    Adam Dawes Guest

    Re: Multiple calls of messages, Flash

    A slight variation on a module-level boolean is to use a static boolean in
    the procedure. This would allow multiple procedures to be running "at once",
    but won't allow re-entry into each individual procedure if it already being
    used.

    To do this:

    Private Sub cmdExample_Click()

    Static sbInHere As Boolean

    'Are we already in this procedure?
    If Not sbInHere Then
    'No -- indicate that we are now
    sbInHere = True

    'do the rest of the procedure code here

    'Finished, clear the InHere flag
    sbInHere = False
    End If


    Using both this and Colin's method, don't forget to reset the boolean if any
    errors occur! Otherwise you may find that you're locked out of the procedure
    until you restart the application.

    --

    Adam.


    Colin McGuigan <colin@chicor.com> wrote in message
    news:39070f42$1@news.devx.com...
    > Jacek Bator wrote in message <3906ff58$1@news.devx.com>...
    > >
    > >I'am working with vb6 and I have problem.
    > >I have form and buttons, when i press the button some action is called

    and
    > >it's beening executed,
    > >when i press this button another time, another action is called and

    > executed
    > >even if previous one didn't
    > >finished. Is there any way to solve this problem not at code level

    > (semaphores
    > >etc.), because for example
    > >with flash OCX errors ocures inside of this control, when i disable

    > it(OCX)everything
    > >is ok, but after enabling it again i sometimes
    > >get calls of some mesages.
    > >
    > >Best Regards
    > >Jacek Bator
    > >jbator@man.poznan.pl

    >
    > Disable the button and set the mouse pointer to an hourglass. When it
    > finishes, re-enable the button, and set the mouse pointer back to normal.
    > You can also use a module level Boolean as a sort of semaphore; the
    > procedure can check the value of the Boolean. If it's True, then the
    > procedure does nothing and exits. Otherwise, it sets it to True, does its
    > work, and then, when done, sets it to False. This would prevent the code
    > from running more than once at a time.
    >
    > --
    > Colin McGuigan
    >
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center