Exemplo n.º 1
0
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult result)
        {
            if (OperationCache == null)
            {
                return(InnerOperationInvoker.InvokeEnd(instance, out outputs, result));
            }

            OperationCachingInvokerAsyncResult asyncResult = result as OperationCachingInvokerAsyncResult;

            if (asyncResult == null)
            {
                throw new ArgumentException("Invalid AsyncResult", "result");
            }
            OperationCachingInvokerAsyncResult.End(asyncResult);

            if (asyncResult.IsNewResult)
            {
                OperationCacheKey   key   = new OperationCacheKey(asyncResult.Action, asyncResult.Inputs);
                OperationCacheValue value = new OperationCacheValue(asyncResult.Outputs, asyncResult.ReturnValue);
                OperationCache.Insert(key, value);
            }

            outputs = asyncResult.Outputs;
            return(asyncResult.ReturnValue);
        }
        public static void End(IAsyncResult asyncResult)
        {
            if (asyncResult == null)
            {
                throw new ArgumentNullException("result");
            }

            OperationCachingInvokerAsyncResult outputResult = asyncResult as OperationCachingInvokerAsyncResult;

            if (outputResult == null)
            {
                throw new ArgumentException("Invalid AsyncResult", "result");
            }
            AsyncResult.End(outputResult);
        }