Share via


WaitForChangedResult 结构

包含关于所发生更改的信息。

**命名空间:**System.IO
**程序集:**System(在 system.dll 中)

语法

声明
Public Structure WaitForChangedResult
用法
Dim instance As WaitForChangedResult
public struct WaitForChangedResult
public value class WaitForChangedResult
public final class WaitForChangedResult extends ValueType
JScript 支持使用结构,但不支持进行新的声明。

示例

此示例演示如何通过让 FileSystemWatcher 等待特定文件更改通知发生来同步使用 FileSystemWatcher

Imports System.IO

Module Module1
    Sub Main()
        ' Define a path and a file name for a temporary file.
        Dim pathname As String = "C:\"
        Dim filename As String = "JunkFile.tmp"
        Dim filepathname As String = Path.Combine(pathname, filename)

        ' Create the temporary file and then close it.
        File.Create(filepathname).Close()

        Console.WriteLine("This application will terminate when you delete the {0} file", filepathname)

        ' Have a FileSystemWatcher monitor the path and file for changes.
        Dim fsw As New FileSystemWatcher(pathname, filename)
        fsw.NotifyFilter = NotifyFilters.FileName
        fsw.EnableRaisingEvents = True

        ' Suspend the calling thread until the file has been deleted.
        Dim cr As IO.WaitForChangedResult = fsw.WaitForChanged(WatcherChangeTypes.Deleted)

        ' Tell the user the file is deleted and exit.
        Console.WriteLine("The {0} files is deleted; program is exiting", cr.Name)
    End Sub
End Module

' This code produces the following output.
' 
'  This application will terminate when you delete the C:\JunkFile.tmp file
'  The JunkFile.tmp files is deleted; program is exiting

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

WaitForChangedResult 成员
System.IO 命名空间
FileSystemEventArgs 类
FileSystemEventHandler 委托
FileSystemWatcher 类
InternalBufferOverflowException 类
NotifyFilters 枚举
RenamedEventArgs 类
RenamedEventHandler 委托
WaitForChanged
WatcherChangeTypes