Exemple #1
0
        public void ThrowsAnExceptionWhenStopAfterDispose()
        {
            var api = new Mock <IRasConnectionNotification>();

            var target = new RasConnectionWatcher(api.Object);

            target.Dispose();

            Assert.Throws <ObjectDisposedException>(() => target.Stop());
        }
Exemple #2
0
        private void Run()
        {
            // Start watching for connection changes.
            watcher.Start();

            Console.WriteLine("Press any key to stop watching for connection changes...");
            Console.ReadKey(true);

            // Stop watching for connection changes.
            watcher.Stop();
        }
Exemple #3
0
        public void StopWillResetTheApi()
        {
            var api = new Mock <IRasConnectionNotification>();

            api.Setup(o => o.IsActive).Returns(true);

            var target = new RasConnectionWatcher(api.Object);

            target.Stop();

            api.Verify(o => o.Reset(), Times.Once);
        }
Exemple #4
0
        private async Task RunCoreAsync()
        {
            watcher.Start();

            while (ShouldContinueExecution())
            {
                using var tcs = CancellationTokenSource.CreateLinkedTokenSource(CancellationSource.Token);

                try
                {
                    await RunOnceAsync(tcs.Token);
                }
                finally
                {
                    await WaitForALittleWhileAsync(tcs.Token, false);
                }
            }

            watcher.Stop();
        }