internal DirMonCompletion(DirectoryMonitor dirMon, string dir, bool watchSubtree, uint notifyFilter) { this._dirMon = dirMon; NativeFileChangeNotification notification = new NativeFileChangeNotification(this.OnFileChange); this._rootCallback = GCHandle.Alloc(notification); int hr = UnsafeNativeMethods.DirMonOpen(dir, HttpRuntime.AppDomainAppIdInternal, watchSubtree, notifyFilter, notification, out this._ndirMonCompletionPtr); if (hr != 0) { this._rootCallback.Free(); throw FileChangesMonitor.CreateFileMonitoringException(hr, dir); } this._ndirMonCompletionHandle = new HandleRef(this, this._ndirMonCompletionPtr); Interlocked.Increment(ref _activeDirMonCompletions); }