none
Removing a persistent handler?

    Question

  • Hello,

    I've been doing a lot of work lately trying to implement some "modular" CCR services.

    All of my services inherit from CcrServiceBase so they take a DispatcherQueue in the constructor.  Depending on what the service does (which ports it exposes publicly), I attach persistent receivers to the ports in the constructor pointing to my asynchronously-implemented-but-synchronous-looking iterators.

    So, let's say I have an application with a single DispatcherQueue and I want to create a number of services that use that queue.  All I have to do is create new service instances, passing the DispatcherQueue to the constructor and they all wire themselves up.

    However, what if I want to remove a particular service from my application?  Is there a way to detach persistent receivers?

    I guess it's easy to see how to construct my service, but I'm having difficulty figuring out how to tear everything down in such a way that the garbage collector will be able to dispose of everything related to the now-unneeded service.

    Also, what should I do with the ports?

    Has anyone else encountered a similar scenario?

    I suppose that I could just let each service have its own DispatcherQueue, but I'm not sure how many services I will have.  I'd like to really scale things up, and I think that sharing the DispatcherQueue among all service instances will allow that, whereas having a DispatcherQueue for each service would start to severly limit things as I scale up.

    Thanks!



    Wednesday, November 26, 2008 8:28 PM

Answers

  • You can use an Interleave with two receivers. One in exclusive or concurrent group (your "persistent" one) and one in the Teardown group (for exemple a non persistent receiver on a bool port).
    When the receiver in the Teardown group is activated, it waits for running exclusive or concurrent to end, removes all arbiters attached to the Interleave and executes itself.
    documentation here http://msdn.microsoft.com/en-us/library/bb796515.aspx

    But the application that you describe look like DSS. You should take a look to it.

    Vincent
    Thursday, November 27, 2008 7:37 AM