I'm writing a simple Windows WCF service as a singleton using the recommended InstanceContextMode.Single service behavior, e.g.:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
My code looks like below. The question is, how can I tell from within my constructor (or otherwise) that the very first call to my service has been made? That is, when the singleton has been instantiated for the first (and only) time?
I need to do some special processing on the first call to the service and the constructor seems like the logical place to do this. However, I've tried placing some simple code in the constructor and can't even hit a breakpoint there (using remote debugging). It's like the constructor is never actually called if I go with the InstanceContextMode.Single route (as opposed to the old classic method of having a static class and a static reference to an object, checking a reference to that object in the constructor to see if it's null, etc.) And, I wouldn't know what to check in the constructor even if I could place functional code there.
Have I lost the ability to check for my first call by going the InstanceContextMode.Single route?
Aucun commentaire:
Enregistrer un commentaire