|
-
Sep 8th, 2007, 12:08 PM
#1
Thread Starter
Addicted Member
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
Last edited by Kyjan; Sep 8th, 2007 at 03:04 PM.
Reason: Title was incorrect
-
Sep 8th, 2007, 11:46 PM
#2
Fanatic Member
Re: Question on performance (events vs. timer)
Use an event because every time the event is fired you know something is going in or out of the queue. The timer will cycle forever wasting time if nothing is happening.
-
Sep 13th, 2007, 08:00 PM
#3
Thread Starter
Addicted Member
Re: Question on performance (events vs. timer)
Yes, but what would happen in this scenario?
1. The program opens and one communication happens.
2. A screen is opened in the program and 5 communications happen at the same time (5 separate requests for information).
If the limit is set to 3 communications at a time, then how would I use events to make sure all communications get processed in the queue as well as blocking the code in the calling user control/form from running? (The results of the communication need to go back to the caller for the code to continue.) Wouldn't I need to use timers?
Kyjan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|