Exemplo n.º 1
0
        /// <summary>
        /// Launch an Task.
        /// </summary>
        /// <param name="startTaskProto"></param>
        private void StartTask(StartTaskProto startTaskProto)
        {
            lock (_contextLock)
            {
                ContextRuntime currentActiveContext = _topContext;
                string         expectedContextId    = startTaskProto.context_id;
                if (!expectedContextId.Equals(currentActiveContext.Id, StringComparison.OrdinalIgnoreCase))
                {
                    var e = new InvalidOperationException(
                        string.Format(CultureInfo.InvariantCulture, "Task expected context '{0}' but the active context has Id '{1}'", expectedContextId, currentActiveContext.Id));
                    Utilities.Diagnostics.Exceptions.Throw(e, LOGGER);
                }

                var configuration = _serializer.FromString(startTaskProto.configuration);
                currentActiveContext.StartTaskOnNewThread(configuration);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Start the context manager. This initiates the root context.
        /// </summary>
        public void Start()
        {
            lock (_contextLock)
            {
                _topContext = _rootContextLauncher.GetRootContext();
                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Instantiating root context with Id {0}", _topContext.Id));

                if (_rootContextLauncher.RootTaskConfig.IsPresent())
                {
                    LOGGER.Log(Level.Info, "Launching the initial Task");
                    try
                    {
                        _topContext.StartTaskOnNewThread(_rootContextLauncher.RootTaskConfig.Value);
                    }
                    catch (TaskClientCodeException e)
                    {
                        Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Exception when trying to start a task.", LOGGER);
                        HandleTaskInitializationException(e);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Start the context manager. This initiates the root context.
        /// </summary>
        public void Start()
        {
            lock (_contextLock)
            {
                _topContext = _rootContextLauncher.GetRootContext();
                LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Instantiating root context with Id {0}", _topContext.Id));

                if (_rootContextLauncher.RootTaskConfig.IsPresent())
                {
                    LOGGER.Log(Level.Info, "Launching the initial Task");
                    try
                    {
                        _topContext.StartTaskOnNewThread(_rootContextLauncher.RootTaskConfig.Value);
                    }
                    catch (TaskClientCodeException e)
                    {
                        Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Exception when trying to start a task.", LOGGER);
                        HandleTaskInitializationException(e);
                    }
                }
            }
        }