VB6 Application Overwhelmed by Rapid User Interaction

June 22nd, 2008 - 05:15 pm ET by Joseph Geretz | Report spam
I have a VB6 app with a somewhat complication user interface screen. The UI
consists of a grid through which the user can navigate from entry to entry.
As each entry is focused, data is retrieved from the application database
(synchronous) while, at the same time, an embedded browser control is
implemented to bring up a web application interface for the focused entry.
This latter operation is inherently asynchronous.

If the user clicks reasonably, or even moderately quickly from entry to
entry the application behaves fine. However if the user will 'attack' the
interface by scrolling rapidly up and down the grid from entry to entry, up,
up, up, down, down, down, up, up, up, down, down, down etc. in rapid
succession, the application will throw an unanticipated application failure;
AppName has encountered a problem and needs to close. We are sorry for the
inconvenience. Etc. This particular type of error is trapped by the Windows
environment, it's not trapped within my application and so I can't take
steps to even trap this condition and rectify it. All I can do is try to
implement code which will prevent it.

What I've done is to insert Me.Enabled = False and Me.Enabled = True to
bracket the RowColChange event of the grid. This doesn't seem to be working
because it seems as though keystrokes which are queued up while the form is
disable are held in the queue and then fed to the UI as soon as the Form
becomes enabled again. Thus, locking the interface doesn't do anything to
cut down on the rapidfire navigation.

I've tried a couple of approaches to try to clear the keyboard buffer prior
to re-enabling the form, but noeither of these seem to work. I've tried a
DoEvents statement just prior to Me.Enabled = True. And I've tried to use
SetKeyboardState as well to flush the keyboard buffer, but neither of these
approaches seems to work. If these were working I'd expect to hit down,
down, down, down, down but just see the focused lineitem move down two rows
since after moving to the first row the interface would be locked, and if
the interface is ready to unlock just prior to the fifth down, I'd expect
keystrokes 2 - 4 to be flushed. But that's not happening. What's hapening is
the keystrokes are all queued, eventually the application UI gets
overwhelmed, and the application crashes.

I appreciate any advice which you can provide.

Thanks!

Joseph Geretz
email Follow the discussionReplies 8 repliesReplies Make a reply

Similar topics

Replies

#1 RB Smissaert
June 22nd, 2008 - 06:44 pm ET | Report spam
How about something simple like this:

Option Explicit
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private lStartTime As Long
Private Const lWaitTime As Long = 200

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If timeGetTime() - lStartTime < lWaitTime Then
KeyCode = 0
Exit Sub
Else
lStartTime = timeGetTime()
End If

End Sub


RBS


"Joseph Geretz" wrote in message
news:%
I have a VB6 app with a somewhat complication user interface screen. The UI
consists of a grid through which the user can navigate from entry to entry.
As each entry is focused, data is retrieved from the application database
(synchronous) while, at the same time, an embedded browser control is
implemented to bring up a web application interface for the focused entry.
This latter operation is inherently asynchronous.

If the user clicks reasonably, or even moderately quickly from entry to
entry the application behaves fine. However if the user will 'attack' the
interface by scrolling rapidly up and down the grid from entry to entry,
up, up, up, down, down, down, up, up, up, down, down, down etc. in rapid
succession, the application will throw an unanticipated application
failure; AppName has encountered a problem and needs to close. We are
sorry for the inconvenience. Etc. This particular type of error is trapped
by the Windows environment, it's not trapped within my application and so
I can't take steps to even trap this condition and rectify it. All I can
do is try to implement code which will prevent it.

What I've done is to insert Me.Enabled = False and Me.Enabled = True to
bracket the RowColChange event of the grid. This doesn't seem to be
working because it seems as though keystrokes which are queued up while
the form is disable are held in the queue and then fed to the UI as soon
as the Form becomes enabled again. Thus, locking the interface doesn't do
anything to cut down on the rapidfire navigation.

I've tried a couple of approaches to try to clear the keyboard buffer
prior to re-enabling the form, but noeither of these seem to work. I've
tried a DoEvents statement just prior to Me.Enabled = True. And I've tried
to use SetKeyboardState as well to flush the keyboard buffer, but neither
of these approaches seems to work. If these were working I'd expect to hit
down, down, down, down, down but just see the focused lineitem move down
two rows since after moving to the first row the interface would be
locked, and if the interface is ready to unlock just prior to the fifth
down, I'd expect keystrokes 2 - 4 to be flushed. But that's not happening.
What's hapening is the keystrokes are all queued, eventually the
application UI gets overwhelmed, and the application crashes.

I appreciate any advice which you can provide.

Thanks!

Joseph Geretz



Replies Reply to this message
#2 Joseph Geretz
June 22nd, 2008 - 07:29 pm ET | Report spam
Thanks,

This approach essentially solves the problem. With the paradigm you suggest,
the form remains active, and keystrokes are discarded by the application if
it is not in a state in which it is prepared to receive them. I simply
implemented a form level variable to set a flag while a retrieval is in
progress. While that flag is true, any keystrokes received by the grid are
simply discarded.

This is working well and the app is stable now.

Thanks!

Joseph Geretz

"RB Smissaert" wrote in message
news:
How about something simple like this:

Option Explicit
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private lStartTime As Long
Private Const lWaitTime As Long = 200

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If timeGetTime() - lStartTime < lWaitTime Then
KeyCode = 0
Exit Sub
Else
lStartTime = timeGetTime()
End If

End Sub


RBS


"Joseph Geretz" wrote in message
news:%
I have a VB6 app with a somewhat complication user interface screen. The
UI consists of a grid through which the user can navigate from entry to
entry. As each entry is focused, data is retrieved from the application
database (synchronous) while, at the same time, an embedded browser
control is implemented to bring up a web application interface for the
focused entry. This latter operation is inherently asynchronous.

If the user clicks reasonably, or even moderately quickly from entry to
entry the application behaves fine. However if the user will 'attack' the
interface by scrolling rapidly up and down the grid from entry to entry,
up, up, up, down, down, down, up, up, up, down, down, down etc. in rapid
succession, the application will throw an unanticipated application
failure; AppName has encountered a problem and needs to close. We are
sorry for the inconvenience. Etc. This particular type of error is
trapped by the Windows environment, it's not trapped within my
application and so I can't take steps to even trap this condition and
rectify it. All I can do is try to implement code which will prevent it.

What I've done is to insert Me.Enabled = False and Me.Enabled = True to
bracket the RowColChange event of the grid. This doesn't seem to be
working because it seems as though keystrokes which are queued up while
the form is disable are held in the queue and then fed to the UI as soon
as the Form becomes enabled again. Thus, locking the interface doesn't do
anything to cut down on the rapidfire navigation.

I've tried a couple of approaches to try to clear the keyboard buffer
prior to re-enabling the form, but noeither of these seem to work. I've
tried a DoEvents statement just prior to Me.Enabled = True. And I've
tried to use SetKeyboardState as well to flush the keyboard buffer, but
neither of these approaches seems to work. If these were working I'd
expect to hit down, down, down, down, down but just see the focused
lineitem move down two rows since after moving to the first row the
interface would be locked, and if the interface is ready to unlock just
prior to the fifth down, I'd expect keystrokes 2 - 4 to be flushed. But
that's not happening. What's hapening is the keystrokes are all queued,
eventually the application UI gets overwhelmed, and the application
crashes.

I appreciate any advice which you can provide.

Thanks!

Joseph Geretz






Replies Reply to this message
#3 RB Smissaert
June 23rd, 2008 - 02:13 am ET | Report spam
Nice one.

RBS


"Joseph Geretz" wrote in message
news:uGNHf%
Thanks,

This approach essentially solves the problem. With the paradigm you
suggest, the form remains active, and keystrokes are discarded by the
application if it is not in a state in which it is prepared to receive
them. I simply implemented a form level variable to set a flag while a
retrieval is in progress. While that flag is true, any keystrokes received
by the grid are simply discarded.

This is working well and the app is stable now.

Thanks!

Joseph Geretz

"RB Smissaert" wrote in message
news:
How about something simple like this:

Option Explicit
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private lStartTime As Long
Private Const lWaitTime As Long = 200

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If timeGetTime() - lStartTime < lWaitTime Then
KeyCode = 0
Exit Sub
Else
lStartTime = timeGetTime()
End If

End Sub


RBS


"Joseph Geretz" wrote in message
news:%
I have a VB6 app with a somewhat complication user interface screen. The
UI consists of a grid through which the user can navigate from entry to
entry. As each entry is focused, data is retrieved from the application
database (synchronous) while, at the same time, an embedded browser
control is implemented to bring up a web application interface for the
focused entry. This latter operation is inherently asynchronous.

If the user clicks reasonably, or even moderately quickly from entry to
entry the application behaves fine. However if the user will 'attack'
the interface by scrolling rapidly up and down the grid from entry to
entry, up, up, up, down, down, down, up, up, up, down, down, down etc.
in rapid succession, the application will throw an unanticipated
application failure; AppName has encountered a problem and needs to
close. We are sorry for the inconvenience. Etc. This particular type of
error is trapped by the Windows environment, it's not trapped within my
application and so I can't take steps to even trap this condition and
rectify it. All I can do is try to implement code which will prevent it.

What I've done is to insert Me.Enabled = False and Me.Enabled = True to
bracket the RowColChange event of the grid. This doesn't seem to be
working because it seems as though keystrokes which are queued up while
the form is disable are held in the queue and then fed to the UI as soon
as the Form becomes enabled again. Thus, locking the interface doesn't
do anything to cut down on the rapidfire navigation.

I've tried a couple of approaches to try to clear the keyboard buffer
prior to re-enabling the form, but noeither of these seem to work. I've
tried a DoEvents statement just prior to Me.Enabled = True. And I've
tried to use SetKeyboardState as well to flush the keyboard buffer, but
neither of these approaches seems to work. If these were working I'd
expect to hit down, down, down, down, down but just see the focused
lineitem move down two rows since after moving to the first row the
interface would be locked, and if the interface is ready to unlock just
prior to the fifth down, I'd expect keystrokes 2 - 4 to be flushed. But
that's not happening. What's hapening is the keystrokes are all queued,
eventually the application UI gets overwhelmed, and the application
crashes.

I appreciate any advice which you can provide.

Thanks!

Joseph Geretz










Replies Reply to this message
#4 Dean Earley
June 23rd, 2008 - 04:04 am ET | Report spam
Joseph Geretz wrote:
I have a VB6 app with a somewhat complication user interface screen. The UI
consists of a grid through which the user can navigate from entry to entry.
As each entry is focused, data is retrieved from the application database
(synchronous) while, at the same time, an embedded browser control is
implemented to bring up a web application interface for the focused entry.
This latter operation is inherently asynchronous.

If the user clicks reasonably, or even moderately quickly from entry to
entry the application behaves fine. However if the user will 'attack' the
interface by scrolling rapidly up and down the grid from entry to entry, up,
up, up, down, down, down, up, up, up, down, down, down etc. in rapid
succession, the application will throw an unanticipated application failure;
AppName has encountered a problem and needs to close. We are sorry for the
inconvenience. Etc. This particular type of error is trapped by the Windows
environment, it's not trapped within my application and so I can't take
steps to even trap this condition and rectify it. All I can do is try to
implement code which will prevent it.



I know you have worked around it now by ignoring the keyboard, but does
telling the browser control to stop its previous download before
starting the next help?

Dean Earley ()
i-Catcher Development Team

iCode Systems
Replies Reply to this message
#5 Larry Serflaten
June 23rd, 2008 - 01:46 pm ET | Report spam
"Joseph Geretz" wrote

If the user clicks reasonably, or even moderately quickly from entry to
entry the application behaves fine. However if the user will 'attack' the
interface by scrolling rapidly up and down the grid from entry to entry, up,
up, up, down, down, down, up, up, up, down, down, down etc. in rapid
succession, the application will throw an unanticipated application failure;



I've tried a couple of approaches to try to clear the keyboard buffer prior
to re-enabling the form, but noeither of these seem to work.



I appreciate any advice which you can provide.



In another post you state:

While that flag is true, any keystrokes received by the grid are
simply discarded.



Does that mean that the user is held back from advancing too fast?

I was just going to mention another approach that would allow the
user to move the focus to the row they want, at the speed they
want.

If, instead of calling the DB and web page on a row change, you
store the new row index in a queue, you could use a timer to read
the queue and display the data. That way the user is simply filling
a queue which can happen rapidly, and not overwhelm the system.

The trick to keeping up with the user is, in the timer event, where
you are going to get and show the data, you check the size of the
queue. If the queue has more than one item, remove all but the last
one and use that.

The timer could be set at a rate that will not overwhelm the system,
so that no matter how fast the user types, the data is called up at
a moderate pace

LFS
Replies Reply to this message
Help Create a new topicNext page Replies Make a reply
Search Make your own search