However, I couldn't get a situation where the movement continued when the time consuming task started. I just stopped moving. As Syncfusion has a responsive support I asked them what was wrong and they assembled a full solution from which they said it worked. However, this only seemed to work as they added a Taks.Delay of 5 seconds during which the BusyIndicator moved indeed and then it filled an ObservableCollection of only 34 elements (in a blink of an eye).
When I placed this within a FOR loop so it would add many 1000's of elements the BusyIndicator directly stopped moving once that started. Today I got a new example from them but again this didn't really work as they still had the Task.Delay, then a task with the FOR but loop doing nothing and then a task filling only the 34 elements of the OC, without my FOR loop. Of course I sent them my modified non working sample and maybe in some stage I get a real solution, but in the meantime I wonder if it is possible that their BusyIndicator just never works. Does someone have a BusyIndicator working at all? If so, how?
Below also my modified sample. I now concentrate on the full C# program only to make sure it doesn't fail because (in my application) it runs from X#. From a WPF MainWindow the SfdataGrid_Loaded method is called (residing within a ViewModel). This show the BusyWIndow (a WPF window on which the BusyIndicator is placed) and then should add a small number of elements to the OC databound to a DataGrid x 400.000. It moves a short while but as soon as the FOR loop starts the BusyIndicator stops moving despite all the Async tasks and awaits.
Or maybe someone directly see what this Syncfusion support is doing wrong in the code?
Dick
Code: Select all
async void SfdataGrid_Loaded(object sender, RoutedEventArgs e)
{
this.SfdataGrids.ItemsSource = await (this.DataContext as ViewModel).GetRecords();
}
private async void BusyIndicatorWindow()
{
var window = new BusyWindow();
// Show the busy indicator on the UI thread
await Application.Current.Dispatcher.InvokeAsync(() => window.Show());
}
public async Task<ObservableCollection<Model>> GetRecords()
{
var gdcsource = new ObservableCollection<Model>();
this.BusyIndicatorWindow();
await Task.Run(() =>
{
for(double i = 0;i<4000;i+=0.01)
{
gdcsource.Add(new Model() { EmployeeName="Robert",EmployeeArea="Torino",EmployeeDesignation="Analysts",EmployeeSalary=10000,EmployeeGender="Male" });
gdcsource.Add(new Model() { EmployeeName=null,EmployeeArea="Montreal",EmployeeDesignation="SoftwareEngineer",EmployeeSalary=15000,EmployeeGender="FeMale" });
gdcsource.Add(new Model() { EmployeeName="Nancy",EmployeeArea="Bracke",EmployeeDesignation="Manager",EmployeeSalary=27000,EmployeeGender="FeMale" });
}
}