本文整理匯總了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);
}
}
}