IFileChangeNotificationSystem.StartMonitoring 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
注册一个文件路径,以便通过主机环境进行监视。
public:
void StartMonitoring(System::String ^ filePath, System::Runtime::Caching::OnChangedCallback ^ onChangedCallback, [Runtime::InteropServices::Out] System::Object ^ % state, [Runtime::InteropServices::Out] DateTimeOffset % lastWriteTime, [Runtime::InteropServices::Out] long % fileSize);
public void StartMonitoring(string filePath, System.Runtime.Caching.OnChangedCallback onChangedCallback, out object state, out DateTimeOffset lastWriteTime, out long fileSize);
abstract member StartMonitoring : string * System.Runtime.Caching.OnChangedCallback * obj * DateTimeOffset * int64 -> unit
Public Sub StartMonitoring (filePath As String, onChangedCallback As OnChangedCallback, ByRef state As Object, ByRef lastWriteTime As DateTimeOffset, ByRef fileSize As Long)
参数
- filePath
- String
要监视更改的目录或文件的完全限定物理路径。
- onChangedCallback
- OnChangedCallback
对实现委托的方法的 OnChangedCallback 引用。 当受监视的文件或目录发生更改时,主机环境的接口实现 IFileChangeNotificationSystem 通过调用 OnChangedCallback 类引发事件。
- state
- Object
主机环境提供的状态。 缓存实现和自定义更改监视器应将状态值视为不透明。 但是,必须存储状态,以便在缓存实现调用 StopMonitoring(String, Object) 该方法时将其发送到主机环境。
- lastWriteTime
- DateTimeOffset
此方法返回时,包含写入操作发生的 filePath上次日期和时间。 此参数未初始化传递。 此参数从主机环境返回。
- fileSize
- Int64
此方法返回时,包含受 filePath监视的总大小。 此参数未初始化传递。 此参数从主机环境返回。
注解
此方法由自定义缓存对象和实现主机环境的接口的 IFileChangeNotificationSystem 自定义更改监视器使用,以便向主机环境注册用于监视的文件路径。 该方法 StartMonitoring 由接口的 IFileChangeNotificationSystem 实现者调用,以便注册文件或目录进行更改监视。