![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Hobbyist Programmer
Join Date: Sep 2004
Posts: 207
Rep Power: 5
![]() |
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 |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Sep 2004
Posts: 207
Rep Power: 5
![]() |
Meh, Nothing?!
__________________
_______________________________ BlazingWolf |
|
|
|
|
|
#3 |
|
Programmer
|
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|