Beispiel #1
0
        protected virtual void Dispose(bool isDisposing)
        {
            m_workerSource.Cancel();

            if (m_channel != null)
            {
                try { m_channel.Retire(); }
                catch { }
                finally { }
            }

            AutomationExtensions.RetireAllChannels(this);
        }
Beispiel #2
0
        public void TestChannelWire()
        {
            Reader x1, x2;
            Writer y;

            IRetireAbleChannel c;

            using (new ChannelScope())
            {
                AutomationExtensions.AutoWireChannels(new object[] {
                    x1 = new Reader(),
                    x2 = new Reader(),
                    y  = new Writer()
                });

                c = ChannelManager.GetChannel <int>("input");
            }

            if (x1 == null || !x1.HasChannel || x2 == null || !x2.HasChannel)
            {
                throw new Exception("Autoloader failed to load channel");
            }

            if (ChannelScope.Current != ChannelScope.Root)
            {
                throw new Exception("Unexpected current scope");
            }

            AutomationExtensions.RetireAllChannels(x1);

            if (c.IsRetiredAsync.WaitForTask().Result)
            {
                throw new Exception("Unexpected early retire");
            }

            AutomationExtensions.RetireAllChannels(x2);

            if (!c.IsRetiredAsync.WaitForTask().Result)
            {
                throw new Exception("Unexpected non-retire");
            }

            using (new ChannelScope())
                AutomationExtensions.AutoWireChannels(y = new Writer());

            if (y == null || !y.HasChannel || y.IsChannelRetired)
            {
                throw new Exception("Scope does not appear isolated");
            }
        }