Solved

VB6 -- is there a limit on the number of events that can be queued up?

Posted on 2009-07-10
6
333 Views
Last Modified: 2013-12-04
Consider a complex form in VB6 that has LOTS and LOTS of buttons, dropdowns, etc, some of them kicking off data access calls, and therefore requiring some time (500 ms?) to complete.

It would be possible for the user to kick one of the data-intense processes, then click a bunch more things in that form while the data process caught up.

What would happen?

Is there a limit to the number of those events (not just clicks, but events caused by internal stuff too) which can be kept queued up?

And if the user exceeded this limit ... what would happen?

Would this cause the program to crash without a visible error message?

Thanks for any insight ...
0
Comment
Question by:Daniel Wilson
6 Comments
 
LVL 10

Accepted Solution

by:
peetm earned 300 total points
ID: 24829639
I believe RaiseEvent is synchronous - so I think we're only talking about events on the UI, and timers, dde, ... here, i.e., queued Windows' Messages, which are translated to VB events?

I don't believe there's a way to query the OS about this, and so you'd have to empirically derive the necessary value ... I should think this will get you somewhere close ...

Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_MOUSEMOVE As Long = &H200

Private Sub Command1_Click()

    Dim l As Long

    Do While PostMessage(Me.hwnd, WM_MOUSEMOVE, 0, 0)
   
        l = l + 1
   
    Loop

    Debug.Print l

End Sub

I'll let you run that to see the output - which I found to be surprisingly large!



0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 24829994
hmm ... 10,000.

Even with multiple grids and data sources ... I don't think we're hitting that figure.

Thanks!
0
 
LVL 5

Assisted Solution

by:BrianVSoft
BrianVSoft earned 100 total points
ID: 24829999
That situation is normal to most business forms..
Normally windows doesn't allow any new "Click" to run until the previous process has finished.
If you have long processes, it is normal to allow "User Cancel" options which require the inclusion of the infamous DoEvents statement..
DoEvents will allow the user to Click start other processes..
In any case, It is normal to simply control these processes via a public variable Eg Processing as Boolean
Ie.
Sub Button99_Click
 If Processing then Beep : Exit Sub
 LabelBusy.Visible = True
 Processing = True
   code:::::
 LabelBusy.Visible = False
 Processing = False
End Sub
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 10

Expert Comment

by:peetm
ID: 24830421
It's also possibly the case [as this is undocumented as far as I know] that the 'queue space' is a fixed size, i.e., you'll queue less messages that carry with them heavy data structures - one of the reasons that this is usually 'done' via carrying a fixed-sized pointer.
0
 
LVL 45

Assisted Solution

by:aikimark
aikimark earned 100 total points
ID: 24854500
With this description, I think you are facing a choice between restructuring and managing user expectations.  The later is much simpler...when the user clicks on a control that is associated with a (potentially) long running process, then do the following in that control:

Private Sub cmdGetData()

  Me.MousePointer = vbHourglass

  Me.Enabled = False

  'do the button click work here
 

  Me.Enabled = True

  Me.MousePointer = vbDefault
 

End Sub

Open in new window

0
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 24878923
OK, I think I got this solved by disabling some buttons during long-running operations.  Thanks, everyone!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now