none
How to handle creation/destruction of PerSession server objects?

    Question

  • Hello!

    Could you please tell me, how to handle the creation and destruction service contracts handling object working on PerSession basis?

    For example, when client connects for the first time, handling object on server is created and I need to put this object to internal list and to notify server internal objects, that client has been just connected.
    When for example, client connection is aborted forcefully (for example, connection problems from client side), I guess WCF should finalize object, that was handling client requests. But I need to notify some server objects about client has disconnected and remove the client from internal list before finalizing.

    Can here standard procedure (constructor(), Finalize()) be used? Finalize is not very good here, because garbager collection can take place long after the client has been disconnected. Is there any other solution?
    Saturday, December 09, 2006 4:39 PM

Answers

  • The service constructor is essentially the session constructor, use that as the "session created" notification.

    If you implement IDisposable on the service type, the service model will invoke Dispose() so you will be notified of disposal that way.

    Sunday, December 10, 2006 8:02 AM
    Moderator