抱歉我的英语不好...您好,我已经制作了这个图片框,但是每当我尝试在其中加载新图片时,它什么都不显示,只是一个空的图片框控件。这是我目前的代码:
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();
};
有什么我做错了吗?如果是这样,你能告诉我什么吗?