Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I'm working on a business application (C#, WPF, EF, MVVM). I need to load a bunch of items from database, create view models for them and put them in a window. Is there a way to create the view model in another thread or do something similar to speed up UI?

  1. The approximate average time needed to fetch all items from database = 1s
  2. The approximate average time needed to instantiate all view models = 3s

I'm doing the first part through Loaded event of each item. but the second part is the bottleneck. any insight would be appreciated.

share|improve this question
    
Creating view models in a background thread is generally a bad idea since they need to be bound on controls created on the main thread. I would try to reduce the initialization time first. –  Dtex Jan 8 '14 at 15:15
    
Or employ some layered caching. –  Robert Harvey Jan 8 '14 at 21:07
    
@Dtex: Thanks, I can remove some unnecessary graphics. –  Bizz Jan 8 '14 at 21:37
    
@Robert: can you explain how layer caching can be done? –  Bizz Jan 8 '14 at 21:37
1  

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.