list box help

hitesh 2000

New member
Joined
Jan 16, 2011
Messages
1
Programming Experience
Beginner
hello

i have one project in which i am using listbox as display to let user know
what software is doing internaly, this include i/o opration.
The problem is listbox is late
when the operation is fnished then it respond,s



any help
 
You haven't provided much information but, if I had to guess, I'd say that the problem is that you are doing a lot of processing on the UI thread. Each thread can only do one thing at a time. If you are gathering all your data on the main thread then it is too busy to repaint the UI or to respond to user input, so your app's UI freezes. There are two options:

1. The poor man's way is to do everything on the UI thread and force it to update the UI intermittently. You can call Refresh on the form just to repaint the UI or you can call Application.DoEvents to process all pending events, including Button Clicks, Timer Ticks, etc. The drawback with this method is that it's relatively expensive so you will actually slow down the overall process, plus your UI will still freeze between calls.

2. The proper way to do this sort of thing is to use multi-threading. There are various ways to implement multi-threading but the simplest is to use the BackgroundWorker. Call RunWorkerAsync and do your background work in the DoWork event handler. To update the UI during the operation, call ReportProgress and handle the ProgressChanged event. To update the UI when the operation is complete, handle the RunWorkerCompleted event.
 
Back
Top