private void OnDataProviderStatusChanged(object sender, DataProviderStatusChangedEventArgs e) { if (e.NewStatus == DataProviderStatus.RequestingData || e.NewStatus == DataProviderStatus.ProcessingData) { this.NotifyView(e.NewStatus); } if (e.NewStatus == DataProviderStatus.Initializing || e.NewStatus == DataProviderStatus.ProcessingData) { this.BeginDataUpdate(); } else { if (e.NewStatus == DataProviderStatus.Uninitialized) { if (this.itemsSource != null) { this.BeginDataUpdate(); } else { this.EndDataUpdate(e); } } else { this.EndDataUpdate(e); } } }
private void EndDataUpdate(DataProviderStatusChangedEventArgs e) { if (e.NewStatus == DataProviderStatus.Faulted || e.NewStatus == DataProviderStatus.Uninitialized) { this.layoutController.ScheduleCleanUp(); this.ResumeUpdateService(ListView.UpdateFlags.AllButData); return; } if (!this.isDataProviderUpdating) { // System.Diagnostics.Debug.Assert(false, "Flag not raised properly."); return; } if (e.NewStatus != DataProviderStatus.Ready || !e.ResultsChanged) { return; } //// NOTE: This call comes from another thread and everything related to the UI should be dispatched on the UI thread. //// It will also clear the IndexTree which will definitely throw NullReference exception if some UI operation is requested before Dispatcher is invoked. //// To solve this issue it will be better to create new Layout class and replace the existing one when dispatched to the Main thread. //// this.SetLayoutSource(); this.View.UpdateService.DispatchOnUIThread( true, () => { if (this.CurrentDataProvider.Status != DataProviderStatus.Ready) { // This may happen if during the Dispatching on UI thread we have a change in the provider - e.g. ItemsSource change. return; } if (this.hasPendingDataRefresh) { this.hasPendingDataRefresh = false; this.RefreshData(); return; } this.SetLayoutSource(); this.RestoreCollapsedState(); ListView.UpdateFlags uiUpdateflags = ListView.UpdateFlags.AffectsContent; this.dataChangeFlags = DataChangeFlags.None; this.isDataProviderUpdating = false; System.Diagnostics.Debug.Assert(!uiUpdateflags.HasFlag(ListView.UpdateFlags.AffectsData), "The AffectsData flag should not be raised here!"); this.ResumeUpdateService(uiUpdateflags); this.NotifyView(this.CurrentDataProvider.Status); }); }
/// <summary> /// Raises the Completed event. /// </summary> protected virtual void OnStatusChanged(DataProviderStatusChangedEventArgs args) { if (args == null) { throw new ArgumentNullException("args", "DataProviderStatusChangedEventArgs shoud not be null"); } if (this.Status == args.NewStatus) { return; } this.Status = args.NewStatus; if (this.StatusChanged != null) { this.StatusChanged(this, args); } }
private void XmlaDataProvider_StatusChanged(object sender, DataProviderStatusChangedEventArgs e) { var dataProvider = sender as XmlaDataProvider; if (e.NewStatus == DataProviderStatus.RetrievingData && !this.alreadyUpdated) { Dispatcher.BeginInvoke(new Action(() => { this.CopyProviderSettings(); this.alreadyUpdated = true; })); } else if (e.NewStatus == DataProviderStatus.Ready) { Dispatcher.BeginInvoke(new Action(() => this.alreadyUpdated = false)); } }
private void EndDataUpdate(DataProviderStatusChangedEventArgs e) { if (e.NewStatus == DataProviderStatus.Faulted || e.NewStatus == DataProviderStatus.Uninitialized) { this.CleanUp(); this.ResumeUpdateService(UpdateFlags.AllButData); return; } if (!this.isDataProviderUpdating) { Debug.Assert(RadControl.IsInTestMode, "Flag not raised properly."); return; } if (e.NewStatus != DataProviderStatus.Ready || !e.ResultsChanged) { return; } //// NOTE: This call comes from another thread and everything related to the UI should be dispatched on the UI thread. //// It will also clear the IndexTree which will definitely throw NullReference exception if some UI operation is requested before Dispatcher is invoked. //// To solve this issue it will be better to create new Layout class and replace the existing one when dispatched to the Main thread. //// this.SetLayoutSource(); this.GridView.UpdateService.DispatchOnUIThread( true, () => { if (this.CurrentDataProvider.Status != DataProviderStatus.Ready) { // This may happen if during the Dispatching on UI thread we have a change in the provider - e.g. ItemsSource change. return; } if (this.hasPendingDataRefresh) { this.hasPendingDataRefresh = false; this.RefreshData(); return; } this.updatingData = true; this.GenerateColumns(); this.SetRowLayoutSource(); UpdateFlags uiUpdateflags = UpdateFlags.AffectsContent | UpdateFlags.AffectsDecorations; // check the data update flags and create the appropriate UI update if (this.dataChangeFlags.HasFlag(DataChangeFlags.Group) || this.dataChangeFlags.HasFlag(DataChangeFlags.Filter)) { uiUpdateflags |= UpdateFlags.AffectsColumnsWidth; } var eventArgs = new DataBindingCompleteEventArgs() { ChangeFlags = this.dataChangeFlags, DataView = this.GridView.GetDataView() }; this.dataChangeFlags = DataChangeFlags.None; this.isDataProviderUpdating = false; this.updatingData = false; this.GridView.CommandService.ExecuteCommand(CommandId.DataBindingComplete, eventArgs); Debug.Assert(!uiUpdateflags.HasFlag(UpdateFlags.AffectsData), "The AffectsData flag should not be raised here!"); this.ResumeUpdateService(uiUpdateflags); this.NotifyView(this.CurrentDataProvider.Status); }); }
private void OnProviderStatusChanged(object sender, DataProviderStatusChangedEventArgs e) { this.statusChangedEventsSequence.Add(e); }