Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Thread slow response due to the populating of 50k records file in ViewModel.Source observable collection #4688

Open
1 of 3 tasks
maxzaikin opened this issue Jun 8, 2023 · 0 comments
Labels
bug The issue relates to the wizard not working or a problem with the generated code. Needs: Triage 🔍

Comments

@maxzaikin
Copy link

Describe the bug

Dear Friends,

first of I would like to appreciate your framework. It is really amazing tool and realy enjoy it. However I'm facing some wierd spec. effect.
I has generated project for DataGrid population with 50 k records from csv file. all works good untill I starting populating ViewModel.Source property this is realy hanging main UI thread. I did moved as much as possible code to the async style but the best i get is slow response UI. Here is how moved my code to the async:

`
public async Task<IEnumerable> ProcessCSVData(string csvFilePath, CSVDataService service)
{

    Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();

    List<ADUserObject> userObjects = new List<ADUserObject>();

    Source.Clear();

    var enumerator = service.SeedCSVFileDataAsync(csvFilePath);

    Source = new ObservableCollection<ADUserObject>();
    await foreach (var item in enumerator.WithCancellation(CancellationToken.None))
    {
        userObjects.Add(item);
        Source.Add(item);
    }

    return userObjects;
}

`

What's intersting is that 50k records gets populated in my List for couple of ms, but once I starting use add thouse to the datagrid observable source property Source.Add(item); the things are getting really bad.

I do understand that the root cause are tons of CollectionUpdate events so I tried to cheat and re-populate Source after I get all data red in my collection as follow:
Source = new ObservableCollection<ADUserObject>(userObjects);
but once i applied this Observable collection stops receiving any events so it end's up empty no matter what you do. I may guess here that the problem is that by the time when I re-initialize Observable collection property it get's hard coded by the comipler in *.g.cs files so it broke some logic somwehre...

I'm really not claim that this is a bug, but If could help me to improve my logick and get main UI thread responsive while it populates 50k lines in Source prop I would be very apprecaite you.

Best regards,
Maks.

To Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Additional context

No response

Applies to the following platforms:

  • WinUI
  • WPF
  • UWP

About your setup

  • Visual Studio Version: 2022 Pro with latest updates:
  • Template Studio Wizard Version: 5.4
  • Windows Build: Windows 11 Pro 22H2 OS Build 22621.1778
@maxzaikin maxzaikin added the bug The issue relates to the wizard not working or a problem with the generated code. label Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue relates to the wizard not working or a problem with the generated code. Needs: Triage 🔍
Projects
None yet
Development

No branches or pull requests

1 participant