2

I did it, but too much exceptions occur 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(); }
}

The code above can get image and sent to main form, however RAM increase up 2GB within 1 minute. I don't understand why, without i turned timer off but RAM not decrease till close subform. Why or any solution ?

trinvh
  • 1,500
  • 2
  • 11
  • 20
  • Please rephrase your question. It is difficult to tell what is being asked here. Side note: If you're not disposing of your `Bitmap`s, what do you expect will happen to your system resources? – Simon Whitehead Feb 18 '13 at 03:31
  • I don't know where to dispose Bitmap s, I tried to dispose it after set to picturebox but the application is broke in Program.cs at new Mainform(). – trinvh Feb 18 '13 at 03:37
  • Don't dispose when you set it.. dispose the old one when you set a new one. E.g: `this.pic.Image.Dispose(); this.pic.Image = img;`. – Simon Whitehead Feb 18 '13 at 03:42
  • Thanks for your help, however it's not solution. RAM still increase... – trinvh Feb 18 '13 at 03:52

0 Answers0