0

Working with DevExpress 2012 vol 2.10 C# on top of VS 2010

First question seems to have been unclear... So lets clear it a bit (or try to at least)!

We are building a MainForm with a Ribbon containing many buttons. Every button in the Ribbon is disabled until their respective state is "ready to enable". "ready to enable" depends on one thing : The WinForm_Popup associated with the button has been completely built, including data retrieval and DevExpress.ExpressApp.ListView construction.

  1. Retrieving data from database takes less than 0.1 second
  2. Calling the WinForm_Popup.Show() takles over 15 seconds

We tried to put this in a Thread or a Task, with no success: It crashes on WinForm_Popup.Show() with an exception related to the DragDrop Event.

What I know by now, is Show() method takes long, but I don't have a clue what happens in this method, but constructing the DevExpress.ExpressApp.ListView, which should be taken away from Show (or do it in a Task or Thred maybe).

Or, in other words, having the WinForm_Popup UI completely built as when it's shown but doing this asynchronously (like in a separate Task, for example).

Any idea, advice, help, link, suggestion, tip... Any "thing" ?

MensSana
  • 521
  • 1
  • 5
  • 16
  • Try measuring how much time it takes to retrieve the data if you ToList it first. – It'sNotALie. Jun 07 '13 at 15:57
  • euw, already did, maybe I was unclear, but I wrote "less than 0.1 sec"... actually, the formatting seems to have been "corrupted"! – MensSana Jun 07 '13 at 17:14
  • I know you did, but I'm thinking that the data is actually getting pulled when the form is showed because of lazy loading. – It'sNotALie. Jun 07 '13 at 17:15
  • The standard mistake is to fill a grid of list with tens of thousands of rows of data. Especially slow when you do it too late, after the constructor finished running. Not exactly a real problem, your user will appreciate the 14 seconds respite before having to tackle the monster. – Hans Passant Jun 07 '13 at 17:25
  • You are right, but this is used to give a fast search panel in a manufacturer business application. So to consult the past orders, past items oredered, etc when creating a new order. So I want to enable the button for this window once it's ready to show, not before (and yes, there will be some limitations on data rows displayed, which will keep the loading time under 4 seconds, but the button must show the window in less than half a second... – MensSana Jun 07 '13 at 17:35

2 Answers2

1

Make a new form and make it empty. In the program.cs file change your main form to the new form. Then make the new form constructor be like this:

public newForm()
        {
            this.Hide();
            Thread backTh = new Thread(() =>
                {
                    MainForm mf = new MainForm();
                    mf.Show();
                });
            backTh.Start();
        }
Georgi-it
  • 3,676
  • 1
  • 20
  • 23
  • I definitely need to rewrite my question, the problem not being the MainForm itself, but the "popup" WinForms containing the ListView. What seems to take time is the "popup" WinForm.Show(), as: The data is already loaded, the ListView already created (new), and the ListView already added to the WinForm. So when we call WinForm.Show(), it takes over 15 sec to show, afterwhat I can hide and show very fast. What I want is to show it for the first time as fast as if it was the second time... – MensSana Jun 07 '13 at 17:18
  • If it's loading some information you can not force it to load it in one second. Obviosly the second time the information is already added that's why it's fast – Georgi-it Jun 07 '13 at 17:20
  • Absolutely, so I want to find a way to have it loading in a separate Task, so when the user asks for it, by clicking the button, it pops up very fast... – MensSana Jun 07 '13 at 17:31
  • Give me some code, i am not a magician, i can't know what grid you have and etc. If you are loading the data from the visual studio UI then you should move all that to code and run it in a new thread – Georgi-it Jun 07 '13 at 17:34
  • Ok I will get it in a few, but to tell you a little bit more, DevExpress is a Framework which handles data to the database (Oracle 10g in our case) and loads everything we ask for in memory (on a Business Object classes layer) and then fulfill its own control (here a ListView). – MensSana Jun 07 '13 at 19:11
  • The problem is not at data loading level, but at WinForm creation, building and displaying... If I could figure out how to mimic .Show() behavior without the "show" part of it (just like making the UI BackgroundWorker to do all it has to show this form but not shoing it, and all that in an async manner, aka task or thread). Code has not much to do with what I need, but I'll add it (edit my question) in a few. Thanks a bunch mate. – MensSana Jun 07 '13 at 19:15
0

I would go for the opposite approach, one that is usually used in slow loading systems like a web browser. Why don't you load the form fast, then use a thread to populate your slow loading grid view?

That way, you can have like a spinning hourglass (or something less 1995) that will tell your users that the data is loading.

Eric
  • 19,525
  • 19
  • 84
  • 147
  • Thank you Eric, I like your idea, as we discussed this approach last week... But it's still not good enough yet. I will tell you why in the next comment. – MensSana Jun 10 '13 at 19:07
  • The goal here is to offer 7 popup windows (over a mainWindow Office-like Ribbon) with in each of them a ListView displaying related data to what he's looking at (in "real time"). Therefore, when the user decide to display a customer, the 7 ListViews (in fact, the 7 Ribbon buttons will first get disabled, the data gets retrieved, the ListViews filled and, then, the buttons on the Ribbon gets enabled again so the user can open the popup (of the last 50 orders as an example) and consult the data in less than a sec... – MensSana Jun 10 '13 at 20:58