Question on performance (events vs. timer)

K

Kyjan

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
 
M

Michel Posseth [MCP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top