当前位置: 首页>>代码示例>>C#>>正文


C# FileSystemWatcher.AllocateBuffer方法代码示例

本文整理汇总了C#中System.IO.FileSystemWatcher.AllocateBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystemWatcher.AllocateBuffer方法的具体用法?C# FileSystemWatcher.AllocateBuffer怎么用?C# FileSystemWatcher.AllocateBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileSystemWatcher的用法示例。


在下文中一共展示了FileSystemWatcher.AllocateBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunningInstance

            private const int NAME_MAX = 255; // from limits.h

            /// <summary>Initializes the instance with all state necessary to operate a watch.</summary>
            internal RunningInstance(
                FileSystemWatcher watcher, SafeFileHandle inotifyHandle, string directoryPath,
                bool includeSubdirectories, Interop.libc.NotifyEvents notifyFilters, CancellationToken cancellationToken)
            {
                Debug.Assert(watcher != null);
                Debug.Assert(inotifyHandle != null && !inotifyHandle.IsInvalid && !inotifyHandle.IsClosed);
                Debug.Assert(directoryPath != null);

                _weakWatcher = new WeakReference<FileSystemWatcher>(watcher);
                _inotifyHandle = inotifyHandle;
                _directoryPath = directoryPath;
                _buffer = watcher.AllocateBuffer();
                Debug.Assert(_buffer != null && _buffer.Length > (c_INotifyEventSize + NAME_MAX + 1));
                _includeSubdirectories = includeSubdirectories;
                _notifyFilters = notifyFilters;
                _cancellationToken = cancellationToken;
                FileSystemWatcher.CaseSensitive = true;

                // Add a watch for this starting directory.  We keep track of the watch descriptor => directory information
                // mapping in a dictionary; this is needed in order to be able to determine the containing directory
                // for all notifications so that we can reconstruct the full path.
                AddDirectoryWatchUnlocked(null, directoryPath);

                // Schedule a task to read from the inotify queue and process the events.
                Task.Factory.StartNew(obj => ((RunningInstance)obj).ProcessEvents(),
                    this, CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default);

                // PERF: As needed, we can look into making this use async I/O rather than burning
                // a thread that blocks in the read syscall.
            }
开发者ID:jsalvadorp,项目名称:corefx,代码行数:33,代码来源:FileSystemWatcher.Linux.cs

示例2: RunningInstance

            private const int NAME_MAX = 255; // from limits.h

            /// <summary>Initializes the instance with all state necessary to operate a watch.</summary>
            internal RunningInstance(
                FileSystemWatcher watcher, SafeFileHandle inotifyHandle, string directoryPath,
                bool includeSubdirectories, Interop.Sys.NotifyEvents notifyFilters, CancellationToken cancellationToken)
            {
                Debug.Assert(watcher != null);
                Debug.Assert(inotifyHandle != null && !inotifyHandle.IsInvalid && !inotifyHandle.IsClosed);
                Debug.Assert(directoryPath != null);

                _weakWatcher = new WeakReference<FileSystemWatcher>(watcher);
                _inotifyHandle = inotifyHandle;
                _directoryPath = directoryPath;
                _buffer = watcher.AllocateBuffer();
                Debug.Assert(_buffer != null && _buffer.Length > (c_INotifyEventSize + NAME_MAX + 1));
                _includeSubdirectories = includeSubdirectories;
                _notifyFilters = notifyFilters;
                _cancellationToken = cancellationToken;

                // Add a watch for this starting directory.  We keep track of the watch descriptor => directory information
                // mapping in a dictionary; this is needed in order to be able to determine the containing directory
                // for all notifications so that we can reconstruct the full path.
                AddDirectoryWatchUnlocked(null, directoryPath);
            }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:25,代码来源:FileSystemWatcher.Linux.cs


注:本文中的System.IO.FileSystemWatcher.AllocateBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。