Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 17th, 2006, 12:29 PM   #1
BlazingWolf
Hobbyist Programmer
 
Join Date: Sep 2004
Posts: 207
Rep Power: 5 BlazingWolf is on a distinguished road
Accessing another thread

So...I decided I need to use threads in a program I'm making because they operation I'm trying to do could take 30+ minutes to complete, and the GUI is useless during that time unless I multithread it.

The problem I'm having is updating the UI from the worker thread. I know your supposed to use a delegate to pass the function. But I'm confused as to where the function and delegate are supposed to be place, and how you pass the varible to the function.

My current understand is this...

Thread #1 ( The UI thread )
--code for the function your going to use


Thread #2 ( Worker )
--declare delegate
--control.Invoke( pass delegate with vars)

I am I understanding the placement right? I guess this is really just a matter of understanding delegates which I have never used before.
__________________
_______________________________
BlazingWolf
BlazingWolf is offline   Reply With Quote
Old Apr 18th, 2006, 9:15 PM   #2
BlazingWolf
Hobbyist Programmer
 
Join Date: Sep 2004
Posts: 207
Rep Power: 5 BlazingWolf is on a distinguished road
Meh, Nothing?!
__________________
_______________________________
BlazingWolf
BlazingWolf is offline   Reply With Quote
Old Apr 19th, 2006, 5:19 PM   #3
Pedja
Programmer
 
Join Date: Nov 2005
Location: Belgrade, Serbia & Montenegro
Posts: 31
Rep Power: 0 Pedja is on a distinguished road
Send a message via ICQ to Pedja Send a message via MSN to Pedja Send a message via Yahoo to Pedja
public delegate void VoidStringDelegate(string text);

textBox.Invoke(new VoidStringDelegate(SomeMethod),
new object[]{”Some string”});

//method must have the same signature as delegate
//parameters are passed as array of objects
I guess this is it.
Pedja is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC