Hi, I have an application that processes incoming messages - for a message T there it looks up all the registered IHandler<T> and calls them. When a message arrives, a new Scope is started, so all the handlers resolve the same dependencies. When processing is finished, the scope is disposed. Processing a message can take 5-10 minutes in total.
Now I would like some of the dependencies of the message handlers to have longer lifespans, so they can be used across several messages (the dependencies are expensive to create and change infrequently). Something like this: When "DoStuff" message arrives: - if Dependency exists in the "message" scope, use that - else resolve Dependency from the "global" scope, put a copy into the "message" scope, and use that When "Refresh" message arrives: - remove Dependency from the "global" scope When "DoStuff" message is finished processing: - remove Dependecy from the "message" scope The key thing is that, if the "Refresh" message is processed at the same time as a "DoStuff" message is being processed, then the original Dependency object can still be resolved by the handlers, and the refreshed Dependency is only used for new messages. But I'm not quite sure how to implement this - it seems like I should be able to re-use some elements of the scoped lifestyle to achieve this, but I'm not really sure what. Also, the handlers themselves use typed factories, and I read that the scoped lifestyle doesn't get used in typed factories... Any help/pointers/advice/ideas greatly appreciated! Thanks, -- You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/castle-project-users. For more options, visit https://groups.google.com/groups/opt_out.
