I'm having trouble working out the correct architecture for the following task. I have a GUI in Windows Forms that contains a
ListBox, listing certain architectural layouts. One an item in this list is selected, a custom
Control displays an interactive visualization of the selected layout. Drawing of this interactive diagram is a CPU-intensive task, and can take up to a second on my machine.
The kind of functionality I'm trying to achieve is that if a user wants to quickly scroll through the layouts in the
ListBox (say, holding down the down arrow key), I don't want my computer to sit there thinking about how to draw the layout before it allows the user to do anything else.
The obvious answer is, of course, to run the layout calculations in a separate thread. But how do I make that thread return a whole control? How do I make sure I'm not running two layout calculations at once?
I'm fairly new to this complex GUI business. So the real question is what is the right architecture to implement something like this? This seems like something people do all the time, but finding any suggestions on how to do it properly is really difficult.