469,904 Members | 2,413 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

polling versus event driven...

hey guys.

overview
---------
I'm designing a messaging system that works on the principle of late binding
to the I/O objects, depending on the .Net class libraries present in the
local folder.

I may have an output File.DLL, and ODBC.DLL, that instantiate an abstract
parent to stream data i receive... an input .DLL allows data to be streamed
in.

The application is currently designed to be multithreaded, so that five
input channels maybe monitor at once, and data coming in can be processes
asynchronously.
the problem
------------

The problem I'm having is with the input, where I've got some DLL's, and
messages coming in...
i can either have a polling mechanism (currently instantiated), where each
monitoring thread checks for data, if none exists, then wait some amount of
time before checking again.
i've been asked to look at the other option, setting up an event delegate
system so that when a message arrives on a channel, the thread monitoring
that channel fires an event causing the data to be processed.

I don't see how this event driven mechanism would really benefit, as it
seems all thats happening is the polling (i.e., check for message, if none,
wait for a bit, try again) mechanism is no longer shared between my server
and it's I/O plugin DLL's, but rather placed entirely inside the
application.

does c# use the same thread when an event is called?
am I missing the idea behind events?
are there other alternatives / approaches to this situation?

thanks for your time.
Dan.

Nov 15 '05 #1
1 3090
Hey Daniel,
does c# use the same thread when an event is called?
Yes, the event handler will be run on the same thread the event has been
raised
are there other alternatives / approaches to this situation?
In general, it is always better to use synchronization objects such as
events or mutexes than to poll. I would suggest your plug-ins should use
synchronization objects to notify the listening thread of data available in
the channel being monitored.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:eO**************@TK2MSFTNGP10.phx.gbl... hey guys.

overview
---------
I'm designing a messaging system that works on the principle of late binding to the I/O objects, depending on the .Net class libraries present in the
local folder.

I may have an output File.DLL, and ODBC.DLL, that instantiate an abstract
parent to stream data i receive... an input .DLL allows data to be streamed in.

The application is currently designed to be multithreaded, so that five
input channels maybe monitor at once, and data coming in can be processes
asynchronously.
the problem
------------

The problem I'm having is with the input, where I've got some DLL's, and
messages coming in...
i can either have a polling mechanism (currently instantiated), where each
monitoring thread checks for data, if none exists, then wait some amount of time before checking again.
i've been asked to look at the other option, setting up an event delegate
system so that when a message arrives on a channel, the thread monitoring
that channel fires an event causing the data to be processed.

I don't see how this event driven mechanism would really benefit, as it
seems all thats happening is the polling (i.e., check for message, if none, wait for a bit, try again) mechanism is no longer shared between my server
and it's I/O plugin DLL's, but rather placed entirely inside the
application.

does c# use the same thread when an event is called?
am I missing the idea behind events?
are there other alternatives / approaches to this situation?

thanks for your time.
Dan.


Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dennis Ålund | last post: by
4 posts views Thread by AzizMandar | last post: by
13 posts views Thread by LordHog | last post: by
2 posts views Thread by John Kotuby | last post: by
15 posts views Thread by Phillip B Oldham | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.