Updating a control without interrupting
I saw the post http://www.c-sharpcorner.com/uploadfile/835123/cross-thread-operations-in-C-Sharp/ that allows me to update a control using a new thread, but it still makes the program wait for the thread to complete. why is that? can't i constantly update a control without interrupting the rest of the program? for example, how could i make the listbox in that post count upward constantly but be able to do anything else i want to at the same time?
Sam HobbsPosted Jan 28, 2012, 10:38 PM
I am not sure what you need to do, so if my guess is wrong, then please don't blame me for misunderstanding. Probably what you want to use is a BackgroundWorker. It is designed to do what I think you wat to do and to make it as easy as possible. Using a BackgroundWorker, the DoWork event is the otehr thread. Everythig else is automatically executed in the thread that creates the BackgroundWorker. So you can use the ProgressChanged event to update the ListBox. Look for articles about BackgroundWorker.
Sam HobbsPosted Jan 29, 2012, 10:58 PM
patrickPosted Jan 29, 2012, 7:38 AM
setTime(){
while(true){ label.text = datetime.now.tostring();}
}
setBox1(){
while(true){
items = getitems();
listbox1.items.clear();
for(int i=0;i
}
setBox2(items2){
while(true){
items = getitems2();
listbox2.items.clear();
for(int i=0;i
}
I want to run these constantly without the rest of the program waiting, so i can always display relevant information to my user.