1

I am hosting my WCF service in IIS but using a custom ServiceHostFactory to hook into the Opened event of the ServiceHost.

I use the Opened event to perform some initialization, which should happen only once. By once, i mean its ok to have it every time there is an apppool recycle or IIS reset. But it shouldn't happen for EACH client request.

Binding: BasicHttpBinding

Instance Context Mode: Per Call

My questions are:

  1. Is Opened the correct event for the one-time initialization? As per my tests, it seems so, but just want to take expert opinion.

  2. Does the ServiceHost instance stay "Open" in IIS as long as the AppPool is not recycled or 'Close' is not invoked on the ServiceHost (for whatsoever reason). If that is the case, can we say ServiceHost is similar to a Server socket that keeps accepting connections? Of course it does a lot more in that it creates the runtime environment for the actual service type, but I am just referring to the connection aspect. I think this answer would follow the above one.

Thanks

4

0 に答える 0