Should I remove the BusyChangedEventHandler?

Should I remove the BusyChangedEventHandler?

Old forum URL: forums.lhotka.net/forums/t/10634.aspx


t.kehl posted on Wednesday, August 24, 2011

Hi.

I set this bevor Save() a BusinessObject:

 

            if (this.IsBusy) {
                var wait = new System.Threading.AutoResetEvent(false);
                this.BusyChanged += (p, f) =>
                {
                    if (!this.IsBusy) {
                        wait.Set();
                    }
                };

                wait.WaitOne();
            }

With this, the Object will wait with Save, if it is busy.

Now, does I get a MemoryLeak, when I don't remove the anonymous-Handler after wait.Set()?

Thanks and best regards, Thomas

Copyright (c) Marimer LLC