IFileChangeNotificationSystem.StartMonitoring 方法

定义

向主机环境注册一个要监视的文件路径。

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 实现者调用,以便注册用于监视更改的文件或目录。

适用于