Progress Window for long mainThread operation, Windows Forms
-
Hi, My application requires a long process of going through selected rows in the DataGridView and calculating things, this must be done on the main GUI thread. The user needs to be able to cancel this process but otherwise not have any interaction with the main GUI. I need a popup Progress Window (progressBar, label,cancelButton...) that will tell the user how much of the process is done and give them a chance to cancel. I think I need to create a new thread that will launch a progress window, the progress window will launch a process located on the main thread, and the main thread will comunicate back to the progress window how things are going. I've lookedd for many tutorials but they've all focused on running work on background threads using public variables. Also, I am still very new to programming and this is m first real application. I ask you explain things in as much detail as possible. Thank you!
-
Hi, My application requires a long process of going through selected rows in the DataGridView and calculating things, this must be done on the main GUI thread. The user needs to be able to cancel this process but otherwise not have any interaction with the main GUI. I need a popup Progress Window (progressBar, label,cancelButton...) that will tell the user how much of the process is done and give them a chance to cancel. I think I need to create a new thread that will launch a progress window, the progress window will launch a process located on the main thread, and the main thread will comunicate back to the progress window how things are going. I've lookedd for many tutorials but they've all focused on running work on background threads using public variables. Also, I am still very new to programming and this is m first real application. I ask you explain things in as much detail as possible. Thank you!
maksim310 wrote:
this must be done on the main GUI thread
Why do you think so?
maksim310 wrote:
I think I need to create a new thread that will launch a progress window
No, that's not possible. Only the GUI thread can open windows.
Despite everything, the person most likely to be fooling you next is yourself.
-
maksim310 wrote:
this must be done on the main GUI thread
Why do you think so?
maksim310 wrote:
I think I need to create a new thread that will launch a progress window
No, that's not possible. Only the GUI thread can open windows.
Despite everything, the person most likely to be fooling you next is yourself.
-
So what's the best way to do this then? I'm going to be coloring 5000 data grid view rows different colors, I need to show the user the progress.
maksim310 wrote:
I'm going to be coloring 5000 data grid view rows different colors
Why color so many rows when the user is only going to see a few at a time?? You got some ginormous monitor you're not telling us about?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
maksim310 wrote:
I'm going to be coloring 5000 data grid view rows different colors
Why color so many rows when the user is only going to see a few at a time?? You got some ginormous monitor you're not telling us about?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008Only 15 or so rows will be seen at once, but the Data Grid View will be displaying all 5000 rows and the user will be scrolling looking for certain patterns. This is a scientific program where users will be generating copious amounts of color-coded rows and will need to detect patterns as they scroll. THe only other way I can think of is to paint them as they scrool by, but that might be too slow as well as constantly hang up the GUI. -Max
-
So what's the best way to do this then? I'm going to be coloring 5000 data grid view rows different colors, I need to show the user the progress.
Do the work in a background thread and store the results in a synchronised queue. Run a timer in the GUI thread that get the result from the queue and puts them in the grid. Search the forum for SynchronisedQueue, and you'll find an implementation that I did a while back.
Despite everything, the person most likely to be fooling you next is yourself.