2
불쌍한 영어로 죄송합니다. 안녕하세요,이 그림 상자를 만들었지 만 새 이미지를로드하려고 할 때마다 아무 것도 표시되지 않고 빈 그림 상자 만 표시됩니다. 제어. 이것은 내가 지금 가지고있는 코드입니다.그림 상자의 내용이 업데이트되지 않음
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();
};
내가 잘못하고있는 것이 있습니까? 그렇다면 무엇을 말해 주시겠습니까?
'DoWork' 코드에서 유효한'Image'를'args.Result'에 할당했는지 여부를 디버깅 해 봤습니까? – DonBoitnott
@DonBoitnott 예, 이미지를 할당합니다. –
대리인을 첨부하기 전에 ** 배경 작업자를 실행하는 이유는 무엇입니까? – HuorSwords