我做到了,但发生了太多异常 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;
}
Subform.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没有减少直到关闭子表格。 为什么或任何解决方案?