-
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
-
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
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks