示例#1
0
 /// <summary>
 /// Waits for the asynchronous operation to complete.
 /// </summary>
 /// <param name="asyncResult">The MappingActionAsyncResult object associated with the operation.</param>
 public static void EndDoAction(MappingActionAsyncResult asyncResult)
 {
     if (asyncResult != null && !asyncResult.IsCompleted)
     {
         asyncResult.AsyncWaitHandle.WaitOne();
     }
 }
示例#2
0
        private void RunDoAction(object threadContext)
        {
            MappingActionAsyncResult asyncResult = (MappingActionAsyncResult)threadContext;
            MappingResultState       resultState = new MappingResultState();

            try
            {
                DoAction(asyncResult.PropertyBag, asyncResult.RangeIndex, asyncResult.ActionId);
            }
            catch (LinguisticException linguisticException)
            {
                resultState = linguisticException.ResultState;
            }
            asyncResult.SetResult(asyncResult.PropertyBag, resultState);

            // Don't catch any exceptions.
            try
            {
                asyncResult.AsyncCallback(asyncResult);
            }
            finally
            {
                Thread.MemoryBarrier();
                ((ManualResetEvent)asyncResult.AsyncWaitHandle).Set();
            }
        }
示例#3
0
        /// <summary>
        /// Causes an ELS service to perform an action after text recognition has occurred. For example,
        /// a phone dialer service first must recognize phone numbers and then can perform the "action"
        /// of dialing a number.
        /// </summary>
        /// <param name="bag">A <see cref="MappingPropertyBag">MappingPropertyBag</see> object containing the results of a previous call to
        /// MappingService.MappingRecognizeText. This parameter cannot be set to null.</param>
        /// <param name="rangeIndex">A starting index inside the text recognition results for a recognized
        /// text range. This value should be between 0 and the range count.</param>
        /// <param name="actionId">The identifier of the action to perform.
        /// This parameter cannot be set to null.</param>
        /// <param name="asyncCallback">An application callback delegate to receive callbacks with the results from
        /// the action operation. Cannot be set to null.</param>
        /// <param name="callerData">Optional. Private application object passed to the callback function
        /// by a service after the action operation is complete. The application must set this parameter to null
        /// to indicate no private application data.</param>
        /// <returns>A <see cref="MappingActionAsyncResult">MappingActionAsyncResult</see> object describing the asynchronous operation.</returns>
        public MappingActionAsyncResult BeginDoAction(MappingPropertyBag bag, int rangeIndex, string actionId, AsyncCallback asyncCallback, object callerData)
        {
            MappingActionAsyncResult result = new MappingActionAsyncResult(callerData, asyncCallback, bag, rangeIndex, actionId);

            ThreadPool.QueueUserWorkItem(this.RunDoAction, result);
            return(result);
        }
        /// <summary>
        /// Causes an ELS service to perform an action after text recognition has occurred. For example, a phone dialer service first must
        /// recognize phone numbers and then can perform the "action" of dialing a number.
        /// </summary>
        /// <param name="bag">
        /// A <see cref="MappingPropertyBag">MappingPropertyBag</see> object containing the results of a previous call to
        /// MappingService.MappingRecognizeText. This parameter cannot be set to null.
        /// </param>
        /// <param name="rangeIndex">
        /// A starting index inside the text recognition results for a recognized text range. This value should be between 0 and the range count.
        /// </param>
        /// <param name="actionId">The identifier of the action to perform. This parameter cannot be set to null.</param>
        /// <param name="asyncCallback">
        /// An application callback delegate to receive callbacks with the results from the action operation. Cannot be set to null.
        /// </param>
        /// <param name="callerData">
        /// Optional. Private application object passed to the callback function by a service after the action operation is complete. The
        /// application must set this parameter to null to indicate no private application data.
        /// </param>
        /// <returns>A <see cref="MappingActionAsyncResult">MappingActionAsyncResult</see> object describing the asynchronous operation.</returns>
        public MappingActionAsyncResult BeginDoAction(MappingPropertyBag bag, int rangeIndex, string actionId, AsyncCallback asyncCallback, object callerData)
        {
            var result = new MappingActionAsyncResult(callerData, asyncCallback, bag, rangeIndex, actionId);

            try
            {
                ThreadPool.QueueUserWorkItem(RunDoAction, result);
                return(result);
            }
            catch
            {
                result.Dispose();
                throw;
            }
        }
示例#5
0
 /// <summary>
 /// Waits for the asynchronous operation to complete.
 /// </summary>
 /// <param name="asyncResult">The MappingActionAsyncResult object associated with the operation.</param>
 public static void EndDoAction(MappingActionAsyncResult asyncResult)
 {
     if (asyncResult != null && !asyncResult.IsCompleted)
     {
         asyncResult.AsyncWaitHandle.WaitOne();
     }
 }
示例#6
0
 /// <summary>
 /// Causes an ELS service to perform an action after text recognition has occurred. For example,
 /// a phone dialer service first must recognize phone numbers and then can perform the "action"
 /// of dialing a number.
 /// </summary>
 /// <param name="bag">A <see cref="MappingPropertyBag">MappingPropertyBag</see> object containing the results of a previous call to
 /// MappingService.MappingRecognizeText. This parameter cannot be set to null.</param>
 /// <param name="rangeIndex">A starting index inside the text recognition results for a recognized
 /// text range. This value should be between 0 and the range count.</param>
 /// <param name="actionId">The identifier of the action to perform.
 /// This parameter cannot be set to null.</param>
 /// <param name="asyncCallback">An application callback delegate to receive callbacks with the results from
 /// the action operation. Cannot be set to null.</param>
 /// <param name="callerData">Optional. Private application object passed to the callback function
 /// by a service after the action operation is complete. The application must set this parameter to null
 /// to indicate no private application data.</param>
 /// <returns>A <see cref="MappingActionAsyncResult">MappingActionAsyncResult</see> object describing the asynchronous operation.</returns>
 public MappingActionAsyncResult BeginDoAction(MappingPropertyBag bag, int rangeIndex, string actionId, AsyncCallback asyncCallback, object callerData)
 {
     MappingActionAsyncResult result = new MappingActionAsyncResult(callerData, asyncCallback, bag, rangeIndex, actionId);
     try
     {
         ThreadPool.QueueUserWorkItem(this.RunDoAction, result);
         return result;
     }
     catch
     {
         result.Dispose();
         throw;
     }
 }