System.Threading.CountdownEvent.Wait C# (CSharp) Method

Wait() private method

private Wait ( Func waitPredicate ) : bool
waitPredicate Func
return bool
		bool Wait (Func<bool> waitPredicate)
		{
			SpinWait wait = new SpinWait ();
			
			while (!IsSet) {
				if (waitPredicate ())
					return false;
				wait.SpinOnce ();
			}
			
			return true;
		}
		

Usage Example

        public void be_able_to_subscribe_to_non_existing_stream()
        {
            const string stream = "be_able_to_subscribe_to_non_existing_stream";
            using (var store = BuildConnection(_node))
            {
                store.ConnectAsync().Wait();
                var appeared = new ManualResetEventSlim(false);
                var dropped = new CountdownEvent(1);

                var subscription = store.SubscribeToStreamFrom(stream,
                                                               null,
                                                               CatchUpSubscriptionSettings.Default,
                                                               (_, x) => appeared.Set(),
                                                               _ => Log.Info("Live processing started."),
                                                               (_, __, ___) => dropped.Signal());

                Thread.Sleep(100); // give time for first pull phase
                store.SubscribeToStreamAsync(stream, false, (s, x) => { }, (s, r, e) => { }).Wait();
                Thread.Sleep(100);
                Assert.IsFalse(appeared.Wait(0), "Some event appeared.");
                Assert.IsFalse(dropped.Wait(0), "Subscription was dropped prematurely.");
                subscription.Stop(Timeout);
                Assert.IsTrue(dropped.Wait(Timeout));
            }
        }
All Usage Examples Of System.Threading.CountdownEvent::Wait