Learn more. Asked 8 years, 8 months ago. Active 8 years, 8 months ago. Viewed 9k times. Add a comment. Active Oldest Votes. In short, you can't. This means you can't start your service with the system. IIS worker processes are recycled i. For example, a worker process is restarted if no HTTP request comes in for a long time.
This means you can't control when your service is shut down, unless you have access to application pool recycling configuration. Keep in mind that the recycling logic only ensures that all pending HTTP requests are complete, but does not await all background threads to complete. You can come with a partial solution this way: Create a WCF service method that checks if your long-running thread is alive and if not, starts it. Create a very simple windows service that periodically once in 5 seconds calls that method.
Deploy the service somewhere, e. Pavel Gatilov Pavel Gatilov 7, 1 1 gold badge 25 25 silver badges 41 41 bronze badges. You cant, in a nut shell. I have a. I have also incorporated http polling using kestrel server.
Can anyone please tell me how can I achieve this because I can't find any helpful material on this? However, I cannot see that when create a worker service application. Maybe you will find other ways to deploy the worker service, but this is not guaranteed to work perfectly on IIS.
You can come with a partial solution this way:. Create a WCF service method that checks if your long-running thread is alive and if not, starts it. Create a very simple windows service that periodically once in 5 seconds calls that method.
Deploy the service somewhere, e. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. The process that hosts your application must remain running once started. Once started, a Windows service process remains running unless explicitly shut down by a server administrator using the service control manager.
Applications that require explicit control over the lifetime of their hosting process should use Windows services instead of IIS or WAS.
Windows service applications are not subject to this restriction and can use any transport WCF supports, including net. Create a Windows service application. You can write Windows service applications in managed code using the classes in the System. ServiceProcess namespace. This application must include one class that inherits from ServiceBase. Link the lifetime of the WCF services to the lifetime of the Windows service application.
Typically, you want WCF services hosted in a Windows service application to become active when the hosting service starts, stop listening for messages when the hosting service is stopped, and shut down the hosting process when the WCF service encounters an error. This can be accomplished as follows:.
0コメント