Exemplo n.º 1
0
        public void TestPostEvent()
        {
            Expect.Once.On(mock_disp)
            .Method("Dispatch");

            Expect.Once.On(mock_disp)
            .Method("Dispose");

            server.PostEvent(mock_disp);
            bool w = server.WaitAll(0);

            Assert.IsTrue(w);

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
Exemplo n.º 2
0
        //////////////////////////////////////////////////////////////////////////
        void doStop(object dummy)
        {
            /*
            The method returns immediately to the caller after initiating the following steps to be taken on another thread.

            1.This Framework's state is set to Bundle.STOPPING.
            2.All installed bundles must be stopped without changing each bundle's persistent autostart setting.
             * If this Framework implements the optional Start Level Service Specification, then the start
             * level of this Framework is moved to start level zero (0), as described in the Start Level
             * Service Specification. Any exceptions that occur during bundle stopping must be wrapped in a
             * BundleException and then published as a framework event of type FrameworkEvent.ERROR
            3.Unregister all services registered by this Framework.
            4.Event handling is disabled.
            5.This Framework's state is set to Bundle.RESOLVED.
            6.All resources held by this Framework are released. This includes threads, bundle class loaders, open files, etc.
            7.Notify all threads that are waiting at waitForStop that the stop operation has completed.
            8.After being stopped, this Framework may be discarded, initialized or started.
            */

            lock (m_lock)
            {
                m_activator.Stop(m_context);

                setState(BundleState.RESOLVED);

                m_eventServer.WaitAll(0);

                m_context.Dispose();
                m_context = null;

                m_bundleRepository = null;
                m_serviceRegistry = null;
                m_eventServer = null;

                m_shutdownResult = new FrameworkEvent(FrameworkEvent.Type.STOPPED, this, null);
                Monitor.PulseAll(m_lock);
            }
        }