本文整理汇总了C#中System.IO.FileSystemWatcher.DispatchEvents方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystemWatcher.DispatchEvents方法的具体用法?C# FileSystemWatcher.DispatchEvents怎么用?C# FileSystemWatcher.DispatchEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.FileSystemWatcher
的用法示例。
在下文中一共展示了FileSystemWatcher.DispatchEvents方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostEvent
private void PostEvent (string filename, FileSystemWatcher fsw, FileAction fa, FileSystemInfo changedFsi) {
RenamedEventArgs renamed = null;
if (fa == 0)
return;
if (fsw.IncludeSubdirectories && fa == FileAction.Added) {
if (changedFsi is DirectoryInfo) {
KeventData newdirdata = new KeventData ();
newdirdata.FSW = fsw;
newdirdata.Directory = changedFsi.FullName;
newdirdata.FileMask = fsw.MangledFilter;
newdirdata.IncludeSubdirs = fsw.IncludeSubdirectories;
newdirdata.Enabled = true;
lock (this) {
StartMonitoringDirectory (newdirdata);
}
}
}
if (!fsw.Pattern.IsMatch(filename, true))
return;
lock (fsw) {
if (changedFsi.FullName.StartsWith (fsw.FullPath, StringComparison.Ordinal))
filename = changedFsi.FullName.Substring (fsw.FullPath.Length + 1);
fsw.DispatchEvents (fa, filename, ref renamed);
if (fsw.Waiting) {
fsw.Waiting = false;
System.Threading.Monitor.PulseAll (fsw);
}
}
}
示例2: DispatchEvents
static void DispatchEvents (FileSystemWatcher fsw, FileAction action, string filename)
{
RenamedEventArgs renamed = null;
lock (fsw) {
fsw.DispatchEvents (action, filename, ref renamed);
if (fsw.Waiting) {
fsw.Waiting = false;
System.Threading.Monitor.PulseAll (fsw);
}
}
}