【问题标题】:How to set timeout feature for FileSystemWatcher?如何为 FileSystemWatcher 设置超时功能?
【发布时间】:2013-06-27 11:08:43
【问题描述】:

抱歉,如果这个问题太简单了,我是这个主题的新手。

我正在创建一些文件,并且需要等到它们完成或直到经过一段时间(这就是我所说的超时)。

FileSystemWatcher 非常适合“等到它们完成”,但我看不到可以控制其寿命的参数。

使用Tread.Sleep 似乎违背了目的(?) - 如果它的用法正确,FileSystemWatcher 将不存在,我们将只存在Tread.Sleep while !File.Exists

那么,实现它的最简单正确的方法是什么?谢谢。

【问题讨论】:

    标签: c# file filesystemwatcher


    【解决方案1】:

    FileSystemWatcher.WaitForChanged Method

    MSDN 系统

    A synchronous method that returns a structure that contains specific information on the change that occurred, given the type of change you want to monitor and the time (in milliseconds) to wait before timing out.

    【讨论】:

      猜你喜欢
      • 2016-11-29
      • 2012-08-26
      • 1970-01-01
      • 2019-01-21
      • 2019-01-27
      • 2017-10-19
      • 1970-01-01
      • 2022-10-05
      • 2012-01-06
      相关资源
      最近更新 更多