私の下手な英語で申し訳ありません... こんにちは、私はこの画像ボックスを作成しましたが、そこに新しい画像を読み込もうとすると、何も表示されず、空の画像ボックス コントロールが表示されます。これは私が現時点で持っているコードです:
var loadImage = new BackgroundWorker();
loadImage.RunWorkerAsync();
// The stuff that is being executed in the backgroundworker.
loadImage.DoWork += (o, args) =>
{
// Loop through the list of items to find the matching picture.
foreach (var item in listItems)
{
if (item.Name == name)
{
try
{
// Get the image.
var request = WebRequest.Create(item.Picture);
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
{
Image image = Image.FromStream(stream);
args.Result = image;
return;
}
}
catch (Exception)
{
}
}
}
};
// Execute this when the backgroundworker is finished.
loadImage.RunWorkerCompleted += (o, args) =>
{
pictureBox1.Image = (Image)args.Result;
Application.DoEvents();
};
私が間違っていることはありますか?もしそうなら、何を教えていただけますか?