私のアプリケーションには、画像への URL のリストがあります。そして、この画像をダウンロードして、Isolated Storage に保存する必要があります。
私がすでに持っているもの:
using (IsolatedStorageFile localFile = IsolatedStorageFile.GetUserStoreForApplication()) {
...
foreach (var item in MyList)
{
Uri uri = new Uri(item.url, UriKind.Absolute);
BitmapImage bitmap = new BitmapImage(uri);
WriteableBitmap wb = new WriteableBitmap(bitmap);
using (IsolatedStorageFileStream fs = localFile.CreateFile(GetFileName(item.url)))//escape file name
{
wb.SaveJpeg(fs, wb.PixelWidth, wb.PixelHeight, 0, 85);
}
}
...
}
このコードは、ファイルの関数内に配置されていApp.xaml.cs
ます。私は多くの解決策を試しましたが、この問題は「無効なクロススレッド アクセス」です。
どうすればそれを機能させることができますか?