public static void Remove(ForegroundTransferRequest request, bool cancelledByQuit = false)
 {
     lock (requestSyncRoot)
     {
         if (requests.Contains(request))
         {
             request.CancelTransfer(cancelledByQuit);
             requests.Remove(request);
         }
     }
 }
 public DownloadItemForegroundViewModel(ForegroundTransferRequest request)
     : base()
 {
     this.ForegroundTransferRequest = request;
     this.WatchTransfer();
 }
 public static void Add(ForegroundTransferRequest request)
 {
     lock (requestSyncRoot)
     {
         requests.Add(request);
     }
     request.StartTransfer();
 }
Exemplo n.º 4
0
        private void DownloadForeground()
        {
            IsolatedStorageFileHelper.CreateDirectoryIfNotExists("/shared/mtransfers");
            ForegroundTransferRequest transferRequest = new ForegroundTransferRequest(new Uri(this.URL, UriKind.Absolute));
            string downloadFile = this.Title + "." + this.Extension;
            transferRequest.DownloadLocation = "shared/mtransfers/" + downloadFile;
            transferRequest.Tag = downloadFile;

            if (!IsolatedStorageFileHelper.CheckIfFileAlreadyDownloading(downloadFile))
            {
                ForegroundTransferService.Add(transferRequest);
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    base.MessengerInstance.Send<Update, DownloadListViewModel>(new Update() { Scope = UpdateScope.Foreground });
                    this.DialogViewService.MessageBoxOk(Main.Info, NewDownload.NewDownloadStarted);
                    this.NavigationViewService.GoBack();
                });
            }
            else
            {
                this.DialogViewService.MessageBoxOkInUIThead(NewDownload.DownloadRequirementsFailed, NewDownload.DownloadSameName);
            }
        }