예제 #1
0
        public void DispatchBarrierAsync()
        {
            TestRuntime.AssertSystemVersion(PlatformName.iOS, 8, 0, throwIfOtherPlatform: false);
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false);

            using (var queue = new DispatchQueue("DispatchBarrierAsync")) {
                var called   = false;
                var callback = new Action(() => called = true);
                queue.DispatchBarrierAsync(callback);
                TestRuntime.RunAsync(TimeSpan.FromSeconds(5), () => { }, () => called);
                Assert.IsTrue(called, "Called");

                called = false;
                using (var dg = new DispatchBlock(callback)) {
                    queue.DispatchBarrierAsync(dg);
                    dg.Wait(TimeSpan.FromSeconds(5));
                }
                Assert.IsTrue(called, "Called DispatchBlock");
            }
        }