/// <summary>
        /// Attach to a pending download operation.
        /// </summary>
        public async void Attach(BT.DownloadOperation downloadOp)
        {
            Debug.Assert(downloadOp != null);

            this.downloadOp = downloadOp;
            this.isAttach = true;
            this.cts = new CancellationTokenSource();
            var progressHandler = new Progress<BT.DownloadOperation>(this.OnDownloadProgress);

            try
            {
                // Since we don't provide API for apps to attach to pending download operations, we have no
                // way to invoke the app event handler to provide any feedback. We would just ignore the result here.
                this.downloadOp = await this.downloadOp.AttachAsync().AsTask(this.cts.Token, progressHandler);
            }
            catch
            {
                // Ignore errors as well. 
            }
        }
        /// <summary>
        /// Called when a progress event is raised from the BT.UploadOperation and this
        /// will call this TailoredUploadOperation's progress handler.
        /// </summary>
        private void OnUploadProgress(BT.UploadOperation uploadOp)
        {
            Debug.Assert(uploadOp != null);

            if (uploadOp.Progress.Status == BT.BackgroundTransferStatus.Error ||
                uploadOp.Progress.Status == BT.BackgroundTransferStatus.Canceled
                || this.isAttach
                || this.Progress == null)
            {
                return;
            }

            this.Progress.Report(
                new LiveOperationProgress(
                    (long)uploadOp.Progress.BytesSent,
                    (long)uploadOp.Progress.TotalBytesToSend));
        }
        /// <summary>
        /// Called from the BTS.DownloadOperation progress event and raise this's download progress.
        /// </summary>
        private void OnDownloadProgress(BT.DownloadOperation downloadOp)
        {
            Debug.Assert(downloadOp != null);

            if (downloadOp.Progress.Status != BT.BackgroundTransferStatus.Error &&
                downloadOp.Progress.Status != BT.BackgroundTransferStatus.Canceled)
            {
                if (!this.isAttach)
                {
                    if (this.Progress != null)
                    {
                        this.Progress.Report(
                            new LiveOperationProgress(
                                (long)downloadOp.Progress.BytesReceived,
                                (long)downloadOp.Progress.TotalBytesToReceive));
                    }
                }
            }
        }