473,406 Members | 2,705 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,406 software developers and data experts.

Question on performance (events vs. timer)

Greetings to all!

I have a question about events vs. timers. I want to know what you
guys think and/or have experienced. Thank you in advance for reading
this!

I have an object that communicates back and forth with a web service.
Now, this object is currently instantiated in all forms where I need
to communicate with the web service. This works fine; however, I can
have an instance where multiple requests are going off at the same
time, even from the same form (I have user controls that
asynchronously communicate as well).

I want to create a "collection" type of class that manages how many
requests are being made at a given time (no more than a set limit).
The class would hold a collection of these web communicators.

My question is this. Performance wise (and any other considerations I
may not be thinking about), would it be better to have a method on the
collection class that raises an event in the communicator object,
telling it to communicate, or would it be better to have a timer
running in the collection class that every so often (500-1000ms), it
checks the queue to see if there are any pending communication
requests and fires them off.

Thoughts?

Thanks!

Kyjan

Sep 8 '07 #1
1 1002
In terms of perfomance , i would personally choose an event driven modell
the reaction would be faster , cause in worst case you are wasting N
milliseconds with waiting
you are not wasting processor cycles.

but this is just my opinion
regards
Michel

"Kyjan" <Ho***********@gmail.comschreef in bericht
news:11**********************@57g2000hsv.googlegro ups.com...
Greetings to all!

I have a question about events vs. timers. I want to know what you
guys think and/or have experienced. Thank you in advance for reading
this!

I have an object that communicates back and forth with a web service.
Now, this object is currently instantiated in all forms where I need
to communicate with the web service. This works fine; however, I can
have an instance where multiple requests are going off at the same
time, even from the same form (I have user controls that
asynchronously communicate as well).

I want to create a "collection" type of class that manages how many
requests are being made at a given time (no more than a set limit).
The class would hold a collection of these web communicators.

My question is this. Performance wise (and any other considerations I
may not be thinking about), would it be better to have a method on the
collection class that raises an event in the communicator object,
telling it to communicate, or would it be better to have a timer
running in the collection class that every so often (500-1000ms), it
checks the queue to see if there are any pending communication
requests and fires them off.

Thoughts?

Thanks!

Kyjan

Sep 8 '07 #2

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

Similar topics

1
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able...
11
by: Steve Jorgensen | last post by:
I've recently been playing with some UI ideas that require the user of a timer to drive animation. The problem I'm having is that Access routinely stops firing timer events for long periods of...
1
by: Mvk | last post by:
Hi; I have a little "timer"-application. The timer starts running when I press the "CTRL + Space" buttons. The timer ends when I click again on "CTRL + Space". Resetting the timer: "CTRL +...
8
by: BolineC | last post by:
I am trying to use a timer in a simplistic windows service... In my OnStart method, I declare and initialize the System.Threading.Timer, and set it to fire every 30 seconds. In my callback...
1
by: Chuck | last post by:
I am creating a pub/sub broker implementation in C# and I am having some trouble understanding how I should best implement the invoke portion in order to make sure it is as thread-safe as it can...
1
by: Apu Nahasapeemapetilon | last post by:
Hello and thank you in advance for your help. Can anyone think of a reason why this code would work properly on one PC, but not another? I've got a System.Windows.Forms.UserControl that...
5
by: Tom | last post by:
Using multiple System.Timers.Timer objects in a Windows Service for performing multi-thread activities in a periodic fashion. Timers are AutoReset=false, to only have a single timer execution...
13
by: Jordan | last post by:
All, I have a UI form calling a class object that contains a timer that routinely draws intensive information to the screen (~30 fps). The drawing is invoked on the main UI thread. I need the...
2
by: PJ6 | last post by:
I'm pushing my CPU to its limit with a realtime physics simulation to learn more about coding for performance. In the simplest case, I have a form that, on a timer tick, drives the physics model...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.