网络波动时如何恢复下载流? [英] How resume download stream while network fluctuation ?

查看:81
本文介绍了网络波动时如何恢复下载流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,

我使用服务下载文件,而下载文件网络已关闭。在这种情况下如何恢复下载。

I have download file using service, while downloading file network has down. In this case how to resume download.

例如:24%下载蒸汽网络后已经关闭。所以我想从24%下载流。

for example: after 24% downloading steam network has down. So I want to download stream from 24%.

你能帮我解决一下这个问题吗?

Can you please help me how to implement ?

谢谢,

Siva Varri

Siva Varri

来自msdn的线程响应

Thread response from msdn

推荐答案

<希瓦瓦里,

欢迎来到开发通用Windows应用论坛! 

请阅读粘贴帖子,特别是  发布指南:主题行标签 &absp; 已知的
Windows 10 SDK及其他问题ls 

Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools 

我们对您的项目类型不太确定,因此我们需要您确认项目类型和设备。

We are not so sure of your project type so we need you to confirm the project type and device.

In这篇文章,我假设您正在编写Windows通用应用程序。

In this post, I assume you are writing a Windows Universal App.

您可以考虑使用 BackgroundDownloader类,帮助您下载
内容,相关示例
后台传输样本,它们是此场景的背景。

You can consider use the BackgroundDownloader class to help you download the content, and the related sample is Background Transfer sample, they are the background of this scenario.

然后我将描述如何恢复和下载您的文件。请参阅以下内容:

Then I will describe how we can resume and download your file. Please see the following:


  1.   DownloadOperation class
  2. BackgroundTransferStatus枚举

对于DownloadOperation。我们可以使用downloadOperation.Pause();暂停下载,我们也可以使用
downloadOperation.Resume();恢复下载 。 Resume方法将帮助我们恢复下载。

For the DownloadOperation. We can use downloadOperation.Pause(); to pause the download, we can also use downloadOperation.Resume(); to resume the download. The Resume method will help us resume the download.

对于他的BackgroundTransferStatus。我们可以检测到这样的进度:

For he BackgroundTransferStatus. We can detect the progress like this:

Progress<DownloadOperation> progress = new Progress<DownloadOperation>(progressChanged);




然后尝试以下方法检测进度并告诉客户网络失败:

And then try the following to detect the progress and tell the customer network failed:

private void progressChanged(DownloadOperation downloadOperation)
        {         
            switch (downloadOperation.Progress.Status)
            {
                case BackgroundTransferStatus.Running:
                    {                     
                    }
                case BackgroundTransferStatus.PausedByApplication:
                    {
                        //Enable the resume button here.
                    }
                case BackgroundTransferStatus.PausedCostedNetwork:
                    {                        
                    }

               case BackgroundTransferStatus.PausedNoNetwork:
                    {
                        TextBlockStatus.Text = "No network detected. Please check your internet connection.";
                        break;
                    }
                case BackgroundTransferStatus.Error:
                    {      
                    }
            }
        }

祝你好运,

Barry


这篇关于网络波动时如何恢复下载流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆