Example #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);
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the SolveOperationAsyncSolveTask class.
        /// </summary>
        /// <param name="operation">The reference to the solve operation to be executed by
        /// the task.</param>
        public SolveOperationAsyncSolveTask(
            ISolveOperation <TSolveRequest> operation)
        {
            Debug.Assert(operation != null);

            _operation = operation;
        }
        /// <summary>
        /// Creates a new task for executing the specified solve operation.
        /// </summary>
        /// <typeparam name="TSolveRequest">The type of the solve request for the operation.
        /// </typeparam>
        /// <param name="operation">The solve operation to be executed by the task.</param>
        /// <returns>A new instance of the <see cref="T:ESRI.ArcLogistics.Routing.IAsyncSolveTask"/>
        /// for executing the specified solve operation.</returns>
        public static IAsyncSolveTask FromSolveOperation <TSolveRequest>(
            ISolveOperation <TSolveRequest> operation)
        {
            Debug.Assert(operation != null);

            return(new SolveOperationAsyncSolveTask <TSolveRequest>(operation));
        }