public void Dispose()
        {
            if (_main != null)
            {
                EPServiceProviderManager.GetProvider(_engineURI).EPAdministrator.DestroyAllStatements();
            }

            try {
                _simulationThread.Interrupt();
                _simulationThread.Join();
            }
            catch (ThreadInterruptedException e) {
                Log.Info("Interrupted", e);
            }
            _main = null;
            Log.Info("StockTicker-example stopped.");
        }
        public void PostInitialize()
        {
            Log.Info("Starting StockTicker-example for engine URI '" + _engineURI + "'.");

            try {
                _main                          = new StockTickerMain(_engineURI, true);
                _simulationThread              = new Thread(() => _main.Run());
                _simulationThread.Name         = GetType().FullName + "-simulator";
                _simulationThread.IsBackground = true;
                _simulationThread.Start();
                _main.Run();
            }
            catch (Exception e) {
                Log.Error("Error starting StockTicker example: " + e.Message);
            }

            Log.Info("StockTicker-example started.");
        }
        public void Dispose()
        {
            if (_main != null)
            {
                EPRuntimeProvider.GetRuntime(_runtimeURI)
                .DeploymentService
                .UndeployAll();
            }

            try {
                _simulationThread.Interrupt();
                _simulationThread.Join();
            }
            catch (ThreadInterruptedException e) {
                Log.Info("Interrupted", e);
            }

            _main = null;
            Log.Info("StockTicker-example stopped.");
        }