Sunday 15 July 2012

c# - cannot destroy labels of my buttons -


I am developing a "cache image generator" for a company.
The goal of this form is to calculate pre-all possible button scenarios. In this, some custom buttons are created, take a snapshot, clean all, and start again till again, do not try them all.

My problem is that I can not delete the label inside my custom button.
My custom button is working fine and I can generate the first image.
Because I use the last part of the previous index, the label will fail due to the objects in the name of the second round name, I believe.

In this way, I am trying to destroy everything:

  foreach (my_button b in .raprapper.Controls.OfType & lt; my_button & gt; ()) {B.resume_layout (); B.show (); } This.PerformLayout (); BMP = new bitmap (this.wrapper.Width, this.wrapper.Height); This.wrapper.DrawToBitmap (BMP, new rectangle (0, 0, BMP wide, BMP.)); A.result = bmp; CC = this.wrapper.Controls; This.wrapper.Controls.Clear (); C.Dispose () control in CC (CC); Cc = faucet; GC.Collect ();   

And this is my_button's custom display handler:

  New Public Zero Extract () {this.Dispose (true); } Safe Override Zero (Hair Disposing) {this.currency_label.Dispose (); This.name_label.Dispose (); This.price_label.Dispose (); This.currency_label = this.name_label = this.price_label = null; this. Background image = null; This.Controls.Clear (); Base.Dispose (settlement); }   

I believe that this is not a devastating problem because I randomly receive it:
Invalid cross-threading operation: control 'control name 'The thread accessed from another thread was created on it. Labels Dispos () on call.

Thanks in advance for any help

- edit -

I solved.
The problem was a wrong call on my Mormonline framework that makes everything visible = false = sets. Please delete this question will not be useful

Due to the cross-threading calling exception, this is because you Dispose bool) . Diszow (boolean) can be called by default and calling thread is unspecified for it. It can be from any thread.

Whatever control you have, you do not need to add additional displacement method.

control. Disease method (boolean)

Issues the unmanaged resources used by the control and control of its child and the managed resources Alternatively, release

Anyway, you can deploy your own bitmap if the owner of the bitmap is my_button and no other object will use the same bitmap. You can do this as follows:

  Protected Override Zero (Hair Disposing) {If (disposal) {var background image = it. Background image; this. Background image = null; BackgroundImage.Dispose (); } Base.Dispose (settlement); }   

and displacement () there is no need to recapture the method.

No comments:

Post a Comment