简体   繁体   English

错误 1053:服务没有使用 FileSystemWatcher 及时响应启动或控制请求

[英]Error 1053:The service did not respond to start or control request in timely fashion with FileSystemWatcher

I have created a Windows Service which uses a FileSystemWatcher to look for changes in different directories.我创建了一个 Windows 服务,它使用 FileSystemWatcher 来查找不同目录中的更改。 When I launch the service I am getting the error:当我启动服务时,我收到错误:

Error 1053:The service did not respond to start or control request in timely fashion.

I think that the error is coming from an infinite loop caused by using the using statement in the Watch() method as shown below:我认为错误来自在 Watch() 方法中using语句导致的无限循环,如下所示:

    public FileSystemWatcher Watch()
    {

        FileSystemWatcher watcher;
        using (watcher = new FileSystemWatcher($"C:\\Users\\lashi\\AppData\\Roaming\\Sublime Text 3", _ext))
        {
           
            watcher.NotifyFilter = NotifyFilters.LastAccess
                                 | NotifyFilters.LastWrite
                                 | NotifyFilters.FileName
                                 | NotifyFilters.DirectoryName;

            watcher.IncludeSubdirectories = true;
            // Add event handlers.
            watcher.Changed += OnChanged;
            watcher.Created += OnChanged;
            watcher.Deleted += OnChanged;
            watcher.Renamed += OnRenamed;

            // Begin watching.
            watcher.EnableRaisingEvents = true;

        }
        return watcher;
    }

This is my OnStart() method:这是我的 OnStart() 方法:

    protected override void OnStart(string[] args)
    {
        String userName;
        String expt;
        if (args.Length < 2)
        {
            Console.WriteLine($"FileWatcher <user> <exptName>");
            Console.WriteLine($"Captures files into /temp/<exptName>-log and /temp/<exptName>-files");
            userName = "wost";
            expt = "expt1";
        }
        else
        {
            userName = args[0];
            expt = args[1];
        }
        String lexpt = $"C:\\Users\\lashi\\Desktop\\EMMC_CACHE\\{expt}-log";
        String fexpt = $"C:\\Users\\lashi\\Desktop\\EMMC_CACHE\\{expt}-file";

        if (!Directory.Exists(fexpt))
        {
            Directory.CreateDirectory(fexpt);
        }
        if (!Directory.Exists(lexpt))
        {
            Directory.CreateDirectory(lexpt);
        }
        // File Watcher Launch
        Watcher w = new Watcher(lexpt, fexpt, userName);
        FileSystemWatcher fw = w.Watch();
    }

Can you please help me to find a solution to this issue?你能帮我找到解决这个问题的方法吗? I have tried a lot of suggestions but they don't seem to work.我尝试了很多建议,但它们似乎不起作用。 Thank you!谢谢!

Click here !点击这里 to see how to increase Windows services pipe timeout by editing the registry keys查看如何通过编辑注册表项来增加 Windows 服务管道超时

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误 1053 服务没有及时响应启动或控制请求 - Error 1053 the service did not respond to the start or control request in a timely fashion 错误1053:服务未及时响应启动或控制请求 - Error 1053: the service did not respond to the start or control request in a timely fashion Windows服务无法启动&#39;错误1053:服务未及时响应启动或控制请求&#39; - Windows Service won't start 'Error 1053: The service did not respond to the start or control request in timely fashion' 启动服务:“错误1053:服务未及时响应启动或控制请求” - Starting a service: “Error 1053: The service did not respond to the start or control request in a timely fashion” 错误 1053:安装并运行 WCF 服务时,服务未及时响应启动或控制请求 - Error 1053: The service did not respond to the start or control request in a timely fashion, when intalled and ran a WCF service C#错误1053,服务未及时响应启动或控制请求 - C# Error 1053 the service did not respond to the start or control request in a timely fashion 发生错误1053,服务未及时响应启动或控制请求 - Im getting Error 1053 the service did not respond to the start or control request in a timely fashion 1053 windows服务没有及时响应 - 1053 windows service did not respond in timely fashion 安装Windows服务时出错 - 服务未及时响应启动或控制请求 - Error installing Windows service — The service did not respond to the start or control request in a timely fashion 服务错误1053:无法及时启动 - Service Error 1053: Could not start in timely fashion
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM