Solved

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

Posted on 2009-07-10
6
338 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

777 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