示例#1
0
        public void DeviceLocator_SearchAsync_HandlesConcurrentDispose()
        {
            using (var deviceLocator = new Rssdp.SsdpDeviceLocator())
            {
                System.Threading.ThreadPool.QueueUserWorkItem((reserved) =>
                {
                    System.Threading.Thread.Sleep(50);
                    deviceLocator.Dispose();
                });

                var t = deviceLocator.SearchAsync();

                AggregateException exception = null;
                try
                {
                    t.Wait();
                }
                catch (AggregateException aex)
                {
                    exception = aex;
                }

                Assert.AreNotEqual(null, exception);
                Assert.AreEqual(1, exception.InnerExceptions.Count);
                Assert.AreEqual(typeof(System.ObjectDisposedException), exception.InnerExceptions.First().GetType());
            }
        }
示例#2
0
        public void DeviceLocator_SearchAsync_HandlesConcurrentDispose()
        {
            using (var deviceLocator = new Rssdp.SsdpDeviceLocator())
            {
                System.Threading.ThreadPool.QueueUserWorkItem((reserved) =>
                    {
                        System.Threading.Thread.Sleep(50);
                        deviceLocator.Dispose();
                    });

                var t = deviceLocator.SearchAsync();

                AggregateException exception = null;
                try
                {
                    t.Wait();
                }
                catch (AggregateException aex)
                {
                    exception = aex;
                }

                Assert.AreNotEqual(null, exception);
                Assert.AreEqual(1, exception.InnerExceptions.Count);
                Assert.AreEqual(typeof(System.ObjectDisposedException), exception.InnerExceptions.First().GetType());
            }
        }