Beispiel #1
0
        public static bool WaitForEvent <TSource>([NotNull] WaitForEventSettings <TSource> settings)
        {
            // WARNING: DO NOT DISPOSE THIS
            EventWatcher <TSource> watcher = EventWatcher.Create(settings);

            return(watcher.Wait(settings.Timeout.TotalIntMilliseconds()));
        }
Beispiel #2
0
        public static Task <bool> WaitForEventAsync <TSource>([NotNull] WaitForEventSettings <TSource> settings, CancellationToken token = default(CancellationToken))
        {
            // Short-circuit: already cancelled
            if (token.IsCancellationRequested)
            {
                return(Task.FromResult(false));
            }
            // WARNING: DO NOT DISPOSE THIS
            EventWatcher <TSource> watcher = EventWatcher.Create(settings);

            return(watcher.WaitAsync(settings.Timeout.TotalIntMilliseconds(), token));
        }