c# Empty Web Application - run thread at the server startup event (entry point)
I have a web service project and I want to run a thread in the event of server starts.
- How do I add an entry point to my project?
- how do I register a function to server stop event?
Edit 1
I have added theGlobal.asax.ch
, but it wont stop in the breake point or print to the console
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
De开发者_运维知识库bug.WriteLine("start");//break point
}
...
}
Thanks
If you expose your WCF service through http binding (ws/basic) or if you use whatever kind of service that is expose through http, you can add a global.asax file to you project and code the Application_Start and Application_Stop events.
If it is a WCF service, you can also create you own host factory and code startup event there but then you wont have any equivalent of a stop event.
If you're using classic asp.net webservices, then you can at least do something on application start/stop in a global.asax.
If you're using WCF you might still do the same, see the following thread for more info: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/4fbf8c21-0a13-4eb5-98da-36b6f08150a8/
精彩评论