Re: Interfaces and Events



If this will be a one-off and one or two classes, I don't want to send you
off on into a mess. But if you will be doing a lot of this in your app, it
is a pattern that can bear a lot of fruit and simplify things. For some
background, check out
http://www.eecs.harvard.edu/~mdw/papers/seda-sosp01.pdf
It is server focused, but the same idea is great for client side and UI
update processing as well. Some nice things are: message based, not method
based so it is easy to refactor code and is loosely coupled. It is
naturally pluggable for easy adding and changing Stages, even at runtime.
Each stage can send messages back to itself or any other stage. Shutdown
processing is as easy as sending a stop message which gets sent along your
Stages (this can sometimes be one of the harder issues to handle cleanly
with other patterns). You can throttle and manage speed at each stage as
you have the queue as the focus point. Many others. First, you will need a
bounded-blocking thread safe queue. Here is mine that also have some
examples using pipes and queues and thread pools.
http://channel9.msdn.com/ShowPost.aspx?PostID=161030 I am actually working
on a server using this "SEDA" pattern and seems to make a lot of sense so
far and seems to be clean. I will try to work up something simple and put
in the C9 Sandbox.

--
William Stacey [MVP]

"Bob Jones" <ddaniels@xxxxxxxxxxxxxxxxxx> wrote in message
news:uLH%23QuwNGHA.4052@xxxxxxxxxxxxxxxxxxxxxxx
| William,
|
| Thank you for that. It's a shame I have no idea how to implement what you
| are speaking of. Can you point me (and others reading this) in the right
| direction?
|
| Regards..
|
|
| "William Stacey [MVP]" <william.stacey@xxxxxxxxx> wrote in message
| news:Od%23h6qwNGHA.3896@xxxxxxxxxxxxxxxxxxxxxxx
| > Sounds like a pipeline. Instead of using delegates and events, I would
| > use
| > message passing. Each class will expose a bounded queue (blocking
style)
| > and have a worker thread (or a user TP) block on messages and handle
them
| > as
| > needed.
| >
| > --
| > William Stacey [MVP]
| >
| > <goodoldave@xxxxxxxxx> wrote in message
| > news:1140541382.690505.172370@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| > | Hey everyone, I need some advice concerning Interfaces and delegates.
| > |
| > | I would like to define a delegate inside of an interface (I know a
| > | delegate is a class but hear me out)
| > |
| > |
| > | Here is a sample:
| > |
| > | Interface A
| > |
| > | Class B inherits Interface A
| > |
| > | Program C creates an instance of Class B and needs to consume events
| > | from Class B.
| > |
| > | I would like for Class B to be required to implement the delegates via
| > | Interface A. Is this possible? Is this proper? Can/Should I use an
| > | abstract class for this? Is there a better way?
| > |
| >
| >
|
|


.



Relevant Pages

  • Re: Delegates VS interfaces - some confusion
    ... the reason that an interface with three methods is not relevant is   ... implementor) having a direct access to all three methods? ... delegates) due to security reasons, ... giving us member level polymorphism?! ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Threads, MTA and COM objects
    ... Just seems like too much effort for something that could easily be handled via a simple synchronized queue of delegates. ... Or the simpler technique of just creating a queue of delegates that's consumed on an appropriate STA thread? ... However, if the GUI is secondary to the program, _and_ you have a reliable way of processing the messaging on your main thread, it seems to me that the simplest approach would be to run the GUI on a dedicated second thread that you've set to be STA, and then let all of the COM object stuff happen on the main thread. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Lahman, how ya doing?
    ... There can be times when the queue is completely comatose. ... and code reuse was at the bottom. ... >provided with the object for the original client. ... >use the access interface provided with the service rather than the one ...
    (comp.object)
  • Re: Delegates VS interfaces - some confusion
    ... the reason that an interface with three methods is not relevant is that a three-method interface is different from the single-method characteristic of a delegate. ... That is, with a three-method interface, any code with a reference to an implementor of that interface has access to all three methods. ... wrapping delegates inside ‘CurrentDelegate’ property), ... private void MethodA() ...
    (microsoft.public.dotnet.languages.csharp)
  • altq and IPsec - queue on incoming interface
    ... Sometimes there is really need for ALTQ on incoming traffic: ... There is problem on queue on $ext_if. ... Use route-to loopback interface ... Then apply queue on outgoing traffic from lo0. ...
    (comp.unix.bsd.openbsd.misc)