|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Threads Question - updating UIused the wrong approach here... I have a thread which gathers some information from the internet for my windows application. It gathers the information fine, but I am having a problem when trying to display it. The information is being diplayed in a datagrid, and has about 100 rows. When the thread throws an "Information Has Been Gathered" event (which would essentially be just before the thread has finished) to my main windows app I try to display the information passed in the datagrid. However, the main program throws a 'null exception' at fairly random points during the populating of the datagrid. Sometimes it may throw it whilst displaying row 47, sometimes at row 22, etc.. It seems to me that the thread is finishing before it can complete the UI displaying tasks in the "Information Has Been Gathered" event handler routine. I have tried just getting it to diplay a couple of lines and it works ok. The only way I can get it to work is if I tell the main application to wait for the thread (i.e. thread1.join) before populating the datagrid. This is clearly what I didn't want to do as the program then freezes until the thread has finished. How should I do this? Am I using the right approach? Should I try using a delegate to update the UI from the thread, or will this still not solve the problem? (not used delegates before so new ground for me again) TIA Have a look at Ted Pattison's articles in MSDN Magazine about threads,
delegates and updating the UI http://msdn.microsoft.com/msdnmag/find/?type=Au&phrase=Ted%20Pattison&words=exact Basic Instincts, January 2004 Basic Instincts, May 2004 Basic Instincts, June 2004 Basic Instincts, September 2004 hth, Alan. Thanks Alan - excellent articles. Nearly understand what I'm doing now.
I'll keep at it. <alanto***@users.com> wrote in message Show quoteHide quote news:1137688931.194709.158160@z14g2000cwz.googlegroups.com... > > Have a look at Ted Pattison's articles in MSDN Magazine about threads, > delegates and updating the UI > > > http://msdn.microsoft.com/msdnmag/find/?type=Au&phrase=Ted%20Pattison&words=exact > > > Basic Instincts, January 2004 > Basic Instincts, May 2004 > Basic Instincts, June 2004 > Basic Instincts, September 2004 > > > hth, > Alan. >
Insert data in VB.Net
Copying one project to another create user and add to admin group under local system Run code under diffrent user remove blank strings in arraylist Can I do this on One line of code? system.data.oledb How to insert a page break in multi-page document? Filtering Rows With SQL Select Farsi Font |
|||||||||||||||||||||||