public object InvokeEnd(object instance, out object[] outputs, IAsyncResult asyncResult)
        {
            CachingAsyncResult cachingAsyncResult = asyncResult as CachingAsyncResult;
            CachingUserState   cachingUserState   = cachingAsyncResult.CachingUserState;

            if (cachingUserState.CacheItem == null)
            {
                object result = this.originalInvoker.InvokeEnd(instance, out outputs, cachingAsyncResult.OriginalAsyncResult);
                cachingUserState.CacheItem = new CachedResult {
                    ReturnValue = result, Outputs = outputs
                };
#if Webhosted
                this.GetCache().Insert(cachingUserState.CacheKey, cachingUserState.CacheItem, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(this.cacheDuration));
#else
                this.GetCache().Add(cachingUserState.CacheKey, cachingUserState.CacheItem, DateTimeOffset.UtcNow.Add(TimeSpan.FromSeconds(this.cacheDuration)));
#endif
                return(result);
            }
            else
            {
                InvokerDelegate invoker = ((System.Runtime.Remoting.Messaging.AsyncResult)cachingAsyncResult.OriginalAsyncResult).AsyncDelegate as InvokerDelegate;
                invoker.EndInvoke(out outputs, cachingAsyncResult.OriginalAsyncResult);
                return(cachingUserState.CacheItem.ReturnValue);
            }
        }
        public object InvokeEnd(object instance, out object[] outputs, IAsyncResult asyncResult)
        {
            CachingAsyncResult result = asyncResult as CachingAsyncResult;
            CachingUserState   state  = result.CachingUserState;

            if (state.CacheItem == null)
            {
                object data = _invoker.InvokeEnd(instance, out outputs, result.OriginalAsyncResult);
                state.CacheItem = new CachedOperationResult {
                    Data = data, Outputs = outputs
                };

                CacheServiceHelper.Current.Add(state.CacheKey, state.CacheItem, TimeSpan.FromSeconds(_cacheDuration));

                return(data);
            }
            else
            {
                InvokerDelegate invoker = ((AsyncResult)result.OriginalAsyncResult).AsyncDelegate as InvokerDelegate;
                invoker.EndInvoke(out outputs, result.OriginalAsyncResult);

                return(state.CacheItem.Data);
            }
        }