public AsyncLoadingUIController(ITableAdapter tableAdapter, AsyncBufferredTableData <TTuple> data) { _Adapter = tableAdapter; _AsyncData = data; _AsyncData.Source.LoadingSessionStarted += OnAsyncDataLoadingStarted; _AsyncData.Source.SingleTaskFinished += OnAsyncDataSingleTaskFinished; _AsyncData.Source.LoadingSessionEnded += OnAsyncDataLoadingSessionEnded; }
void Dispose() { // Unsubscribing from events makes this object available for GC if (_AsyncData != null && _AsyncData.Source != null) { _AsyncData.Source.LoadingSessionStarted -= OnAsyncDataLoadingStarted; _AsyncData.Source.SingleTaskFinished -= OnAsyncDataSingleTaskFinished; _AsyncData.Source.LoadingSessionEnded -= OnAsyncDataLoadingSessionEnded; } if (_Adapter != null) { _Adapter.ItemsRefreshed -= OnAdapterItemsRefreshed; } _Adapter = null; _AsyncData = null; }