コード例 #1
0
        /// <summary>
        /// 生成ADB备份
        /// </summary>
        /// <param name="path"></param>
        /// <param name="confirm"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public bool Backup(string path, Func <bool> confirm, Action <ErrorResult> error)
        {
            // 检测连接是否通常
            if (!TryConnect(error))
            {
                return(false);
            }
            var flag = false;
            // 转化为同步方式
            var are    = new AutoResetEvent(false);
            var backup = new BackupHandler(Serial)
            {
                Confirme = confirm,
                Exit     = success =>
                {
                    flag = success;
                    are.Set();
                }
            };

            backup.BeginBackup(path, error);
            // 等待异步任务完成
            are.WaitOne();
            return(flag);
        }