use*_*734 0 c# asp.net windows-services filesystemwatcher
我正在构建一个使用FileSystemWatcher的Windows服务,并在后台运行.
我不希望每次想要调试时都继续卸载和安装服务,因此在将其转换为服务之前,我希望在正常程序中进行大部分开发.但是我对此很新,当我运行它时,它只是通过块然后退出.
什么是保持程序运行的好方法?
http://einaregilsson.com/run-windows-service-as-a-console-program/
我之前使用过这个来根据它是否在交互式用户环境中运行来调试我的服务作为控制台应用程序.
public partial class DemoService : ServiceBase
{
static void Main(string[] args)
{
DemoService service = new DemoService();
if (Environment.UserInteractive)
{
service.OnStart(args);
Console.WriteLine("Press any key to stop program");
Console.Read();
service.OnStop();
}
else
{
ServiceBase.Run(service);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1388 次 |
| 最近记录: |