How to make IIS wait until the WCF service is ready?

I have a WCF service hosted in IIS 7. It will take several minutes until this service finishes loading its data and is ready for external calls. Loading data into internal thread. The problem is that from the IIS point, the service is ready immediately after its activation (by means of some call) and processes the request without waiting for data to load.

Is it possible to inform IIS that the service is still loading and making this service unavailable for requests? No problem if such a request throws an exception.

+3
source share
2 answers

. , , . .

:

public class MyService : IMyService
{
    public MyService()
    {
        // Blocking call that initializes
        // the service instance
        this.Initialize();
    }

    public void GetData()
    {
        // The service operation will be invoked
        // after the service instance has been created
        // at which point the initialization is complete
    }

    private void Initialize()
    {
        // Initialization logic
    }
}

, , , . , , , . , , .

, ServiceHost, OnOpening. IIS, ServiceHostFactory, ServiceHost.
MSDN.

+2

, " - ASP.NET 4 Visual Studio 2010": http://www.asp.net/LEARN/whitepapers/aspnet4/#0.2__Toc253429241

, , IIS 7.5 Windows Server 2008 R2, ASP.NET 2.0 +

+1

Source: https://habr.com/ru/post/1740819/


All Articles