Imagine an InvoiceHeaderGrid and an InvoiceDetailGrid.
Lets's say we have this code in a HeaderGrid's rowchanged event:
DataTable InvoiceDetail = new GetInvoiceDetail(HeaderGrid.CurrentId);
InvoiceDetail.ItemDeleted += (sender, evt) =>
{
};
DetailGrid.DataSource = InvoiceDetail;
so that the code is called every time the user focuses a different row in the HeaderGrid.
The "dead" InvoiceDetail datatable and its attached anonymous handler get garbage-collected with each reassignment of variable InvoiceDetail, right? The attached handler isn't treated as a reference to the object that would prevent it from being garbage-collected?