Ejemplo n.º 1
0
        /// <summary>
        /// Runs the specified solve operation asynchronously.
        /// </summary>
        /// <typeparam name="TSolveRequest">The type of the solve request for the operation.
        /// </typeparam>
        /// <param name="operation">The solve operation to run.</param>
        /// <returns>Identifier of the started operation.</returns>
        private Guid _RunAsync <TSolveRequest>(
            ISolveOperation <TSolveRequest> operation)
        {
            this._NotifyAsyncSolveStarting(new AsyncSolveStartingEventArgs(operation.Schedule));

            var solveTask = AsyncSolveTask.FromDelegate(tracker =>
            {
                _ValidateSolverState();

                var operationTask = AsyncSolveTask.FromSolveOperation(operation);

                return(operationTask.Run(tracker));
            });

            var id = _asyncMgr.RunAsync(solveTask);

            var info = new AsyncOperationInfo
            {
                Id            = id,
                InputParams   = operation.InputParams,
                OperationType = operation.OperationType,
                Schedule      = operation.Schedule,
            };

            _asyncOperations.Add(id, info);

            _NotifyAsyncSolveStarted(id);

            return(id);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Performs solve result processing for the specified solve operation response.
        /// </summary>
        /// <param name="resultProvider">Function returning result of the solve operation.</param>
        /// <returns>A new <see cref="T:ESRI.ArcLogistics.Routing.SolveTaskResult"/> object storing
        /// solve result and the next task to run if any.</returns>
        private SolveTaskResult _ProcessSolveResult(
            Func <SolveOperationResult <TSolveRequest> > resultProvider)
        {
            var result            = resultProvider();
            var nextStepOperation = result.NextStepOperation;

            IAsyncSolveTask nextTask = null;

            if (nextStepOperation != null)
            {
                nextTask = AsyncSolveTask.FromSolveOperation(nextStepOperation);
            }

            return(new SolveTaskResult
            {
                SolveResult = result.SolveResult,
                NextTask = nextTask,
            });
        }