ca1001

Why won't the GC automatically dispose my class's members?

When I build the following C++/CLI code in VS2008, a code analysis warning CA1001 is displayed. ref class A { public: A() { m_hwnd = new HWND; } ~A() { this->!A(); } protected: !A() { delete m_hwnd; } HWND* m_hwnd; }; ref class B { public: B() { m_a = gcnew A(); } protected: A^ m_a; }; warning: CA1...

Is CA1001: TypesThatOwnDisposableFieldsShouldBeDisposable Valid?

If I have the following code: public class Foo { public void Bar() { var someTypeWithAnEvent = new SomeTypeWithAnEvent(); using (var signal = new ManualResetEvent(false)) { someTypeWithAnEvent.Begun += (sender, e) => signal.Set(); someTypeWithAnEvent.Begin(); s...