0

Windows Phone アプリに BugSense を追加し、それに応じて app.xaml.cs を変更しました。ただし、一部のユーザーがクラッシュを経験していることは知っていますが、BugSense では確認されていません。BugSense を使用して新しいセッションを確認し、ライセンスが正しいことを確認します。

このコード内で、特に webclient でクラッシュが発生すると思います。何かが発生した場合に BugSense が報告するようにするには、このコードに何を追加すればよいですか?

 private void LongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        LongListSelector selector = sender as LongListSelector;

        // verifying our sender is actually a LongListSelector
        if (selector == null)
            return;

        SoundData data = selector.SelectedItem as SoundData;

        // verifying our sender is actually SoundData
        if (data == null)
            return;


        if (data.IsDownloaded)
        {
            this.PlaySound(IsolatedStorageFile.GetUserStoreForApplication().OpenFile(data.SavePath, FileMode.Open, FileAccess.Read, FileShare.Read));
        }
        else
        {
            if (!SimpleIoc.Default.GetInstance<INetworkService>().IsConnectionAvailable)
            {
                MessageBox.Show("You need an internet connection to download this sound.");
            }
            else
            {
                WebClient client = new WebClient();

                client.DownloadProgressChanged += (senderClient, args) =>
                    {
                        Dispatcher.BeginInvoke(() =>
                            {
                                data.DownloadProgress = args.ProgressPercentage;
                            });
                    };

                client.OpenReadCompleted += (senderClient, args) =>
                {
                    using (IsolatedStorageFileStream fileStream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(data.SavePath))
                    {
                        args.Result.Seek(0, SeekOrigin.Begin);
                        args.Result.CopyTo(fileStream);

                        this.PlaySound(fileStream);
                        data.Status = DownloadStatus.Downloaded;
                    }

                    args.Result.Close();
                };

                client.OpenReadAsync(new Uri(data.FilePath));
                data.Status = DownloadStatus.Downloading;
            }
        }

        selector.SelectedItem = null;
    }
4

1 に答える 1