public void Start(IProject context, IEnumerable <string> variables)
        {
            if (_project != null || _container != null)
            {
                throw new InvalidOperationException("Cannot start a new online container again.");
            }

            _project = context;
            try
            {
                // Ensure that the container is deleted
                context.OnlineVariableContainerCollection.Delete(_containerName);

                // Create a new container
                _container = context.OnlineVariableContainerCollection.Create(_containerName);

                // Add variables and register Event
                ErrorHandler.ThrowOnError(_container.AddVariable(variables.ToArray()));
                _container.BulkChanged += Container_BulkChanged;

                // Activate OnlineContainer
                ErrorHandler.ThrowOnError(_container.ActivateBulkMode());
                ErrorHandler.ThrowOnError(_container.Activate());

                _logger.Info("OnlineContainer " + _containerName + " successfully started.");
            }
            catch (Exception exception)
            {
                _logger.Error(exception);
            }
        }
        public void Start(IProject context, IEnumerable <string> variables)
        {
            _project = context;

            // Ensure that the container is deleted
            context.OnlineVariableContainerCollection.Delete(_containerName);

            // Create a new container
            _container = context.OnlineVariableContainerCollection.Create(_containerName);

            // Add variables and register Event
            ErrorHandler.ThrowOnError(_container.AddVariable(variables.ToArray()));
            _container.BulkChanged += Container_BulkChanged;

            // Activate OnlineContainer
            ErrorHandler.ThrowOnError(_container.ActivateBulkMode());
            ErrorHandler.ThrowOnError(_container.Activate());
        }
        public void Stop()
        {
            if (_container == null)
            {
                throw new InvalidOperationException("Stop() cannot be called before Start()");
            }

            // All events are removed here - the container gets disabled and deleted.
            _container.BulkChanged -= Container_BulkChanged;

            _container.Deactivate();
            try
            {
                ErrorHandler.ThrowOnError(_project.OnlineVariableContainerCollection.Delete(_containerName));
                _container = null;
                _project   = null;
                _logger.Info("OnlineContainer " + _containerName + " successfully stopped.");
            }
            catch (Exception exception)
            {
                _logger.Error(exception);
            }
        }