Hi Team,
This is regarding UltraCombo Control (Under Namespace - Infragistics.Win.UltraWinGrid, version 13.1)
Scenario :
The ultracombo control is subscribed to dynamic data updates on the fly.
consider the control is initialized with 1500 count on the screen, after sometime say service send some updates with 700 count. The Subscribed event say ListChange() is called where the control's datasource is assigned again.
say,
ultracombo1.DataSource = NewUpdateDataList;
Now if user try to type and search for some records at some cases it throws exception.
Below exception is given :
Requesting the team to shed some light why its working in a weird way.
Please help me understanding what are the possible causes for this issue.
Thanks,
Pratik
It's hard to tell much from this code snippet, but it looks like your data source exists on another thread (other than the UI thread). Using threading and data binding together is extremely tricky and may not be possible. When you use another thread, you are responsible for marshalling the data from the background thread to the UI thread. But when using DataBinding, you are not in control of the communication between the controls in the UI and the data source. So this won't work because there is no way to properly marshal the communication since it happens beyond your control.
There's a long discussion of this here.
If you are going to use threading and data binding together, you must make absolutely sure to completely separate the two. That means that you can never change, edit, or even examine the data source that the grid is bound to on another thread. It means you must retrieve all of the data and marshal it to the UI thread and then bind the grid only to data that has already been marshalled.
Hi Mike,
Thanks for the reply. Yeah you are right i have service which returns a list<ClassA> back.
Just to elaborate more over dynamic updates below is the piece of code
static void ServiceData_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded) { SetRefreshButtonToolTip("Please click 'Update' to refresh the list"); _workItem.CommandManager.RefreshFilterCommand.CanExecute = true; //enables a refresh button when user clicks on it the list updates. this is the recent update we did to avoid the error } }
//Responsible to update the control public void RefreshButton_Click() { _viewModel.OriginalDataList = _Service.GetReferenceData<ClassA>().ToList(); // gets the latest feeds and assign to the view model object ultraCombo1.DataSource = _viewModel.OriginalDataList; // assigning back to control SetRefreshButtonToolTip("Data is up to date"); }
Can you please help me understanding whats going wrong here so i can try to correct and overcome. Else please suggest some solution or pointers to it. If threading is the only issue you see here ill make sure then im on UI thread when it re-assign data back to control.Thanks,
Hi Pratik,
What exactly do you mean by "The ultracombo control is subscribed to dynamic data updates on the fly." The UltraCombo has a DataSource and it listens to notifications from the IBindingList interface. That's the only subscription to notifications that I am aware of.
From your description, this has strong connotations of a threading issue. You mentioned a service and that you are rebinding the UltraCombo to a new data source. My guess is that your service is running on another thread and you are crossing threads here without proper marshaling.