/// <summary>回调函数得到异步线程的返回结果</summary> /// <param name="iAsyncResult"></param> private void RefreshCacheCallBack(IAsyncResult iAsyncResult) { AsyncResult async = (AsyncResult)iAsyncResult; AsyncMethod.AsyncRefreshCacheDelegate asyncDelegate = (AsyncMethod.AsyncRefreshCacheDelegate)async.AsyncDelegate; int iResult = (int)asyncDelegate.EndInvoke(iAsyncResult); if (iResult == 0) { // 执行成功 Dictionary = this.provider.FindAll(string.Empty, 0); } else { // 执行失败 } }
/// <summary>刷新缓存信息</summary> public int RefreshCache() { AsyncMethod.AsyncRefreshCacheDelegate asyncDelegate = delegate() { foreach (ApplicationFeatureInfo cacheItem in Dictionary) { if (string.IsNullOrEmpty(cacheItem.AuthorizationReadScopeObjectText)) { // 此段代码目的是为了初始化授权对象 } } return(0); }; IAsyncResult result = asyncDelegate.BeginInvoke(new AsyncCallback(RefreshCacheCallBack), null); return(0); }