下载大文件时出现异常

时间:2013-04-23 12:22:51

标签: windows-phone-8 out-of-memory

我正在开发一个音频/视频相关应用程序,用户需要下载视频才能在本地播放,为此我使用此代码 -

private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        WebClient wb = new WebClient();


        wb.OpenReadAsync(new Uri("Video url", UriKind.Absolute)); 
        wb.DownloadProgressChanged += wbchange;
    }
    private void wbchange(object sender, DownloadProgressChangedEventArgs e)
    {
          progressBar2.Value = e.BytesReceived;
          progressBar2.Maximum = e.TotalBytesToReceive;   
    }

小视频工作正常,但大视频显示错误 错误是 - System.OutOfMemoryException: Insufficient memory to continue the execution of the program. at MS.Internal.FrameworkCallbacks.NotifyManagedDebuggerOnNativeOOM()

请建议我摆脱这种或任何其他方式下载视频以获得更好的性能?

感谢关注:)

1 个答案:

答案 0 :(得分:0)

对于这种情况,您可以使用Background Transfert Service。 已成功下载大文件(约50 / 60mo)。

仅超过3克或以上。

MSDN: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh286419(v=vs.105).aspx 例如:http://www.jeffblankenburg.com/2011/11/26/31-days-of-mango-day-26-background-file-transfer/