public void Is_Thread_Safe()
        {
            var cb     = new CircuitBreaker();
            var status = new ThreadTestStatus {
                Failed = false
            };
            int threads = 10;

            List <Thread> workerThreads = Enumerable.Range(0, threads)
                                          .Select(i => CreateWorker(cb, status))
                                          .ToList();

            foreach (var thread in workerThreads)
            {
                thread.Start();
            }

            Enumerable.Range(0, 10)
            .ToList()
            .ForEach(i =>
            {
                Assert.False(status.Failed);
                Thread.Sleep(TimeSpan.FromSeconds(1));
            });

            cb.Trip();

            Thread.Sleep(TimeSpan.FromSeconds(1));

            Assert.True(status.Failed);
        }
        private static Thread CreateWorker(CircuitBreaker cb, ThreadTestStatus status)
        {
            return(new Thread(() =>
            {
                while (true)
                {
                    try
                    {
                        cb.Execute(() => ValidOperation(1, 2));
                    }
#pragma warning disable CA1031 // Do not catch general exception types
                    catch (Exception)
#pragma warning restore CA1031 // Do not catch general exception types
                    {
                        status.Failed = true;
                    }

                    Thread.Sleep(TimeSpan.FromSeconds(1));
                }
            }));
        }