0

I have very generic question. I tried google it but couldn't find anything good.

So the question is: I have winform application where based on option selected from menu bar, child form/view is loaded and these child forms are used to display reports.

in order to generate report, these child form contains report selection criteria like date, name etc and these value comes from DB. based on values available in DB, we add controls in the view.

Problem comes when screen takes lots of time to load, it freeze UI/application during loading that I don't want.

I also tried run tasks async but since it is using view during the processing, this option failed.

ThreadPool.QueueUserWorkItem(delegate { method.Invoke(presenter, results); });

presenter is my viewpresenter and results is parameters to invoke it. application concluding presenter name at run time and calling its default method using methodinfo.invoke().

Is there any other way to achive the same.

Point: I cannot redesign the whole application to separate out complete DB logic from UI logic as it is legacy application and this might break the application.

Abhash786
  • 881
  • 2
  • 24
  • 53
  • ... and where is "what you tried" ? – Nikhil Vartak Oct 06 '15 at 04:59
  • From the limited information you've given us would could hardly do more than to suggest separating the DB logic from the UI logic, but you've said we can't do that. So, unless you can give us more detail then I think you're stuck. – Enigmativity Oct 06 '15 at 05:07
  • You need to show all of the code that is related to the issue. You still haven't given us anything to go on. – Enigmativity Oct 06 '15 at 05:21
  • re: `it freeze UI/application during loading that I don't want.` of course not. if you want help, you need to provide all the details behind `it`. there may not be anything anyone can do to speed up the data access or drawing of controls on forms, though. – Beth Oct 06 '15 at 15:09

1 Answers1

0

If "freezing" is the problem, you could use doevents, see here: Use of Application.DoEvents()

Or, you could go the really old fashioned, vb6 way: run the code that freezes your UI synchronously, but from a modal window shown above your ui. You can event present the user with the progress indicator.

Community
  • 1
  • 1
chrisl08
  • 1,658
  • 1
  • 15
  • 24