Inheritance: IDisposable
Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActionBuffer" /> class.
 /// </summary>
 /// <param name="action">The action.</param>
 public ActionBuffer([NotNull] BufferedAction action)
 {
     _action = action;
     if (action.Duration >= 0)
     {
         _timer = new Timer(OnTick, this, action.Duration, Timeout.Infinite);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationFileWatcher"/> class.
        /// </summary>
        /// <param name="path">The path.</param>
        private ConfigurationFileWatcher([NotNull] string path)
        {
            _eventAction = new BufferedAction(WatcherOnChanged, 100);
            Path = path;
            if (!File.Exists(path)) return;

            // ReSharper disable once AssignNullToNotNullAttribute
            _watcher = new FileSystemWatcher(System.IO.Path.GetDirectoryName(path), System.IO.Path.GetFileName(path));
            _watcher.Changed += (s, e) => _eventAction.Run();
            _watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.Size;
            _watcher.EnableRaisingEvents = true;
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ActionBuffer" /> class.
 /// </summary>
 /// <param name="action">The action.</param>
 public ActionBuffer([NotNull] BufferedAction action)
 {
     _action = action;
     _timer = new Timer(OnTick, this, action.Duration, Timeout.Infinite);
 }