Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProxyWatcher"/> class.
 /// </summary>
 /// <param name="marshaller">The marshaller.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="kind">Kind of the watcher.</param>
 /// <param name="path">Path associated with the watcher</param>
 public ProxyWatcher(MarshallerChannel marshaller, ulong id, WatcherKind kind, string path)
 {
     this.marshaller = marshaller;
     this.Id         = id;
     this.Kind       = kind;
     this.Path       = path;
 }
Пример #2
0
 public Watcher(ulong id, WatcherKind kind, WatcherPerformance.IInstrumentation instrumentation, SemaphoreSlim watcherSemaphore)
 {
     this.Id               = id;
     this.Kind             = kind;
     this.instrumentation  = instrumentation;
     this.watcherSemaphore = watcherSemaphore;
     this.lifetime         = Stopwatch.StartNew();
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateWatcher"/> class.
 /// </summary>
 /// <param name="watchedEventDelegate">The delegate to be invoked</param>
 /// <param name="kind">Kind of the watcher</param>
 /// <exception cref="System.ArgumentNullException">Thrown if onProcess is null</exception>
 public DelegateWatcher(Action <WatchedEvent> watchedEventDelegate, WatcherKind kind = WatcherKind.OneUse)
 {
     this.Kind = kind;
     this.watchedEventDelegate = watchedEventDelegate;
     if (watchedEventDelegate == null)
     {
         throw new ArgumentNullException("watchedEventDelegate");
     }
 }
Пример #4
0
 public Watcher(ulong id, WatcherKind kind, Session session)
 {
     this.Id = id;
     this.session = session;
     this.Kind = kind;
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Watcher"/> class.
 /// </summary>
 /// <param name="id">Id of the watcher</param>
 /// <param name="kind">Kind of the watcher</param>
 public Watcher(ulong id, WatcherKind kind)
 {
     this.Id   = id;
     this.Kind = kind;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DelegateWatcher"/> class.
 /// </summary>
 /// <param name="onProcess">The on process.</param>
 /// <param name="kind">Kind of the watcher</param>
 /// <exception cref="System.ArgumentNullException">onProcess cannot be null</exception>
 public DelegateWatcher(Action <WatchedEvent> onProcess, WatcherKind kind = WatcherKind.OneUse)
 {
     this.onProcess = onProcess ?? throw new ArgumentNullException("onProcess");
     this.Kind      = kind;
 }
Пример #7
0
        /// <summary>
        /// Create a watcher that completes a task when notified.
        /// </summary>
        /// <param name="watchedEventTask">The task that will be completed when the watcher is notified</param>
        /// <param name="kind">Kind of the watcher</param>
        /// <returns>Interface to the watcher</returns>
        private static IWatcher CreateWatcher(out Task <WatchedEvent> watchedEventTask, WatcherKind kind = WatcherKind.OneUse)
        {
            var watcherTaskCompletionSource = new TaskCompletionSource <WatchedEvent>();
            var watcher = new DelegateWatcher(
                watchedEvent =>
            {
                Task.Run(() => watcherTaskCompletionSource.SetResult(watchedEvent));
            },
                kind);

            watchedEventTask = watcherTaskCompletionSource.Task;

            return(watcher);
        }