我在运行时将图片加载到图片框中,当有20-30张图片但图片超过50张时,它将正常工作,然后PictureBox LoadAsync随机方法开始发出内存不足异常。
ArrayList imageList = ExtractImagesFromPDF(schedule_pdf);
foreach (var item in imageList)
{
Imagethumnail picbox = new Imagethumnail();
picbox.img.LoadAsync(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
+ "\\" + Convert.ToString(item)
);
picbox.img_name.Text = Convert.ToString(item);
picbox.img.SizeMode = PictureBoxSizeMode.StretchImage;
picbox.Location = new Point(x, y);
picbox.Height = 400;
picbox.Width = 250;
x += picbox.Width + 10;
maxheight = Math.Max(picbox.Height, maxheight);
if (x > this.ClientSize.Width - 100)
{
x = 20;
y += maxheight + 10;
}
this.pnl_imags.Controls.Add(picbox);
}