473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Event consuming

I have a dotNet device (slow as tar) that is doing some really expensive
processes, and I need a way to handle the user clicking a button too
quickly, as I can't keep up with the redraw (1-2 seconds wait time per
click). I feel an event is the way to go, but don't know how to say "if the
event is in the process of being called as it is, stop, and get use the
latest data".

Thanks for dealing with newbies :)

Joshua Moore
Nov 16 '05 #1
5 1882
I think the logic could be like this:

1) In event handler, set some class variable like "inEventProcessing" to
true at the beginning, doing some expensive operation, then set the same
class variable like "inEventProcessing" to false just before exiting event
handler.

2) When user clicks a button, you could check the above variable. If TRUE,
do not fire any event but instead let user know "he should wait for some
time before trying to click again". If FALSE, fire a new event so the above
method will be called again.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Joshua Moore" <gl*****@msn.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
I have a dotNet device (slow as tar) that is doing some really expensive
processes, and I need a way to handle the user clicking a button too
quickly, as I can't keep up with the redraw (1-2 seconds wait time per
click). I feel an event is the way to go, but don't know how to say "if the event is in the process of being called as it is, stop, and get use the
latest data".

Thanks for dealing with newbies :)

Joshua Moore

Nov 16 '05 #2
Joshua,
To prevent UI lockups, please consider using Thread for the time consuming
process in addition to what "Jiachuan Wang" recommended for
"inEventProcessing" class variable. Many CPU intensive processes just make
Form controls really sluggish in responsiveness.
That way you may even alter the priority of background process.

Fakher Halim
"Joshua Moore" <gl*****@msn.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
I have a dotNet device (slow as tar) that is doing some really expensive
processes, and I need a way to handle the user clicking a button too
quickly, as I can't keep up with the redraw (1-2 seconds wait time per
click). I feel an event is the way to go, but don't know how to say "if the event is in the process of being called as it is, stop, and get use the
latest data".

Thanks for dealing with newbies :)

Joshua Moore

Nov 16 '05 #3
Dewiring the event handler during processing and then rewiring it at the
end is another approach that has been suggested:

private void MyEventHandler(object sender, EventArgs e) {
MyEvent -= new EventHandler(MyEventHandler);

// do your processing
.....

MyEvent += new EventHandler(MyEventHandler);
}

This can work better if your class will potentially be handling more
than one event at a time. For example you might want to allow the user
to make another request from a different part of the form.

Are you hourglassing the cursor during processing?

DC
Nov 16 '05 #4
Essentially it's using onClick to see if data is updated, if it is, then it
has to update several things. If the user clicks 5 times, if the event
handler sees that there are more events in the queue, to empty the queue
except the last, and only run the last event.

"D Cameron" <da******@hotmail.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
Dewiring the event handler during processing and then rewiring it at the
end is another approach that has been suggested:

private void MyEventHandler(object sender, EventArgs e) {
MyEvent -= new EventHandler(MyEventHandler);

// do your processing
.....

MyEvent += new EventHandler(MyEventHandler);
}

This can work better if your class will potentially be handling more
than one event at a time. For example you might want to allow the user
to make another request from a different part of the form.

Are you hourglassing the cursor during processing?

DC

Nov 16 '05 #5
The user can press several different buttons, all doing the same
functionality minus the text of each button (minimal speed differences), and
they expect to wait until my verification comes back, so I don't want to
slow down the process waiting for threads to finish and check thread status.
I just want it to act like the Paint event where if it's supposed to repaint
5 times, it skips the first 4, and just does the last paint event, as all
the data is saved per used click. I'm currently setting up a event handler
and trying to dewire the event, but any help of a skeleton layout for what i
need, etc. would be greatly appreciated.

Thanks in advance, and to those already offering suggestions,
Josh

"Fakher Halim" <fa****@msn.com> wrote in message
news:O%***************@TK2MSFTNGP11.phx.gbl...
Joshua,
To prevent UI lockups, please consider using Thread for the time consuming
process in addition to what "Jiachuan Wang" recommended for
"inEventProcessing" class variable. Many CPU intensive processes just make
Form controls really sluggish in responsiveness.
That way you may even alter the priority of background process.

Fakher Halim
"Joshua Moore" <gl*****@msn.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl...
I have a dotNet device (slow as tar) that is doing some really expensive
processes, and I need a way to handle the user clicking a button too
quickly, as I can't keep up with the redraw (1-2 seconds wait time per
click). I feel an event is the way to go, but don't know how to say "if

the
event is in the process of being called as it is, stop, and get use the
latest data".

Thanks for dealing with newbies :)

Joshua Moore


Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rawCoder | last post by:
Hi, I must be missing something here. All I want is to be able to handle the events of one of my class, objects of which are in a collection. For e.g. I have a class MyClass1 which raises...
3
by: John Baro | last post by:
I need to implement an event to notify when a property has changed. Method 1. If I use a generic PropertyChanged event from System.ComponentModel then it will be raised for every property if 1...
2
by: Peter | last post by:
Hello Thanks for reviewing my question. I am trying to consume the Keydown event of the Cntrl-shift-E in a textbox and have noticed that when I press key this combination a beep is made even...
11
by: Tim Jarvis | last post by:
Hi, I have a really frustrating problem.... I have a custom windows form control that contains a collection of controls, these controls in turn contain other controls, a titlebar for example...
1
by: charliewest | last post by:
I would like to implement the following functionality: When a user taps a (child) treeNode, an event fires which allows me to get the selected treeNode's TAG object, determine it's values, and...
4
by: Sergey Muschin | last post by:
Hi there! How to define event in an Interface and then to implement it in a class? Thank You
8
by: Pete | last post by:
Assume I have an n by n matrix of identical objects, each of which can both invoke and consume event A. If, say, obect invokes the event, the only other objects that need to consume it are those in...
0
by: Rusty | last post by:
I'm using a third party tree view control on my web app. I have built a web control that is used throughout the application. When a user clicks on a node in the tree, the nodes click event is...
3
by: Academia | last post by:
If the user types into the TextBox of a combobox it works OK. But if he hold a key down so the letter repeats quickly the code runs into trouble. My questions are: Is it true that an event's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.