コード例 #1
0
                /// <summary>
                /// Dispose handle. This will prevent action being called.
                /// </summary>
                public void Dispose()
                {
                    WatchToken _token = Interlocked.CompareExchange(ref token, null, token);

                    if (_token != null)
                    {
                        _token.UnregisterCallback(this);
                    }
                    action = null;
                    state  = null;
                    token  = null;
                }
コード例 #2
0
        /// <summary>
        /// Enumerate a directory at the given path, if any.
        /// </summary>
        /// <param name="filter">Relative path that identifies the directory.</param>
        /// <returns>Returns the contents of the directory.</returns>
        public IChangeToken Watch(string filter)
        {
            // Assert enabled feature
            if (!options.CanObserve)
            {
                throw new NotSupportedException(nameof(Watch));
            }
            WatchToken          watchToken     = new WatchToken();
            IFileSystemObserver observerHandle = FileSystem.Observe(filter, watchToken, null, null, token);

            Interlocked.CompareExchange(ref watchToken.observerHandle, observerHandle, null);
            return(watchToken);
        }
コード例 #3
0
 public CallbackHandle(WatchToken token, Action <object> action, object state)
 {
     this.token  = token;
     this.action = action;
     this.state  = state;
 }