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方法,以註冊檔案或目錄以進行變更監控。