2

我做到了,但是 Mainform.cs 出现了太多异常

Subform subform = new Subform();
subform.GetCapture += new Subform.GetCapture(SetSubformImage);
subform.Show();
//Set subform image to a pictureBox
void SetSubformImage(Image img) {
this.pic.Image = img;
}

子窗体.cs

public delegate void CaptureHandle(Image img);
public event CaptureHandle GetCapture;
public Image ImgSubForm {
set{
if(GetCapture != null)
GetCapture(value);
}
}
//...Function GetFormImage return current form image
//Event form activated
private void Subform_Activated(object sender, EvenAgrs e) {
timer.Enable = true;
//With timer.Tick += { ImgSubForm = GetFormImage(); }
}

上面的代码可以获取图像并发送到主窗体,但是 RAM 在 1 分钟内增加了 2GB。我不明白为什么,如果我没有关闭计时器,但 RAM 不会减少,直到关闭子窗体。为什么或任何解决方案?

4

0 回答 0