Hello all,

I'm working on an app that takes a huge computational effort. It all works fine, but while calculating all other processes are overruled:

- switching between forms doesn't work while my app is computing
- Progress bars aren't properly refreshed, despite my form.refresh command

So basically I'd like to free some resources every now and then to give other processes a chance too. How do I do that?

Tnx
Siebe

Recommended Answers

All 6 Replies

You can use DoEvents in loops or run you calcuclations in a seperate thread (see BackgroundWorker in ToolBar).

Great, using application.doevents really helped! Now I can toggle between forms without progress bars being stuck and forms showing only half. Thanks!

There's just one thing that keeps buggin me: my DatagridView objects have trouble refreshing.

http://www.learnsobek.com/img/refreshgrid.jpg

As you can see, the upper grid in the example has DaniWeb in the background. This was the result of switching to this website and switching back to the app.

form.refresh doesn't work, and neither does doevents. The only thing that refreshes the grid is selecting each cell. Only after that they'll return to their original backgroundcolor.

Have you tried refreshing the datagrid? DataGrid.Refresh.

Yes I have, I even added a DoEvents method after the refresh method. Doesn't work though

I had a program that did that one time. It seems like I used sleep command to let the computer catch up with my program. Try that.
Thread.Sleep(300)

Oops, I had a property for the background cell style set to 'transparent'..... Sorry for that last posting. Still a bit strange behaviour though. I would expect the background of the form to shine through. In stead it was other applications that did.

Anyway, thanks all for your effort!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.