Ejemplo n.º 1
0
        /// <summary>
        /// 异步解压完成
        /// </summary>
        /// <param name="e">结果</param>
        protected virtual void ClientDecompressCompleted(DecompressDataCompletedEventArgs e)
        {
            //验证
            IPackage package = e.UserState as IPackage;

            if (package == null)
            {
                this.OnError(new ErrorEventArgs("无效的解压操作。"));
                return;
            }
            //用户取消
            if (e.Cancelled)
            {
                this.OnNotify(new NotifyEventArgs("已取消更新。"));
                return;
            }
            //出错
            if (e.Error != null)
            {
                this.OnError(new ErrorEventArgs("解压 {0} 失败:{1}。", package.FileName, e.Error.Message.TrimEnd(PERIOD)));
                return;
            }
            //继续下一个
            this.ClientDownloadAsync();
        }
        /// <summary>
        /// 触发解压完成事件
        /// </summary>
        /// <param name="e">数据</param>
        protected virtual void OnDecompressDataCompleted(DecompressDataCompletedEventArgs e)
        {
            DecompressDataCompletedEventHandler handler = this.Events[EVENT_DECOMPRESS_DATA_COMPLETED] as DecompressDataCompletedEventHandler;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        /// <summary>
        /// 执行解压数据完成回调
        /// </summary>
        /// <param name="error">错误</param>
        /// <param name="cancelled">是否取消</param>
        /// <param name="asyncOp">异步生存期</param>
        private void DecompressDataAsyncCallback(Exception error, bool cancelled, AsyncOperation asyncOp)
        {
            DecompressDataCompletedEventArgs eventArgs = new DecompressDataCompletedEventArgs(error, cancelled, asyncOp.UserSuppliedState);

            this.InvokeOperationCompleted(asyncOp, this.m_DecompressDataOperationCompleted, eventArgs);
        }