Control.Disposing property doesn't work

  • Thread starter Thread starter Sean J Donovan
  • Start date Start date
S

Sean J Donovan

Forgive me, this has probably been in here before.

In a Dispose(..) method, within the IF statement, try testing the
Control.Disposing property. It's always FALSE.

It's quite an irritation.

I would've expected that as soon as Dispose() is called on a Control
instance that it would internally set this to TRUE.

Anyone else noticed this?
Anyone reported it?
Have I missed anything obvious?

Sean
 
private void Form1_Disposed(object sender, EventArgs e

Console.WriteLine(this.Disposing); // returns true
 
Charlie said:
private void Form1_Disposed(object sender, EventArgs e)
{
Console.WriteLine(this.Disposing); // returns true;
}


You're missing the point. The property [Disposing] means that the
control is **being** disposed. When the [Disposed] event is called, the
control has finished disposing.

:-)

Sean
 
Charlie said:
private void Form1_Disposed(object sender, EventArgs e)
{
Console.WriteLine(this.Disposing); // returns true;
}

That's not right is it? When the [Disposed] event is fired, that
signifies that the Disposal is complete. However, the [Disposing]
property signifies that the component is **being** disposed (ie. not
finished yet).

In the case you've given above, you'd expect this.Disposing to be FALSE.
The documentation backs me up here. The first line of the remarks
reads:

"When this property returns true, the control is in the process of being
disposed of."

You bring up a good point, it's a 2nd bug that it's returning TRUE when
the component has already finished disposal.

Sean
 
I would certainly agree that the event is not appropriately named. I posted it just to show that the Disposed porperty it not always false, as you said it was, not to say that your concerns weren't valid.
 
Back
Top