Click here to Skip to main content
15,916,835 members
Home / Discussions / C#
   

C#

 
AnswerRe: Manipulating controls in C#2005 Pin
V.8-Jan-07 22:32
professionalV.8-Jan-07 22:32 
AnswerRe: Manipulating controls in C#2005 Pin
Christian Graus8-Jan-07 23:31
protectorChristian Graus8-Jan-07 23:31 
AnswerRe: Manipulating controls in C#2005 Pin
Bekjong9-Jan-07 1:40
Bekjong9-Jan-07 1:40 
GeneralRe: Manipulating controls in C#2005 Pin
Mr.Sam9-Jan-07 2:13
Mr.Sam9-Jan-07 2:13 
GeneralRe: Manipulating controls in C#2005 Pin
Bekjong9-Jan-07 2:23
Bekjong9-Jan-07 2:23 
GeneralRe: Manipulating controls in C#2005 Pin
Mr.Sam9-Jan-07 2:49
Mr.Sam9-Jan-07 2:49 
GeneralRe: Manipulating controls in C#2005 Pin
Bekjong9-Jan-07 2:59
Bekjong9-Jan-07 2:59 
AnswerRe: Manipulating controls in C#2005 Pin
Luc Pattyn9-Jan-07 2:12
sitebuilderLuc Pattyn9-Jan-07 2:12 
Hi,

if you are lucky you can still do everything on the UI thread by using a
System.Windows.Forms.Timer; your example sure could benefit from it, since
it basically sits sleeping all the time.

if your new thread is there because some real work needs to be done, you could
have that thread set an int progress value, and have a System.Windows.Forms.Timer
with an event handler that updates your progress bar (yes, this is a polling situation,
but hey, it may well be cheaper than the Invoke stuff anayway).

but when your worker thread needs to really interact with one or many controls,
then the InvokeRequired/Invoke/BeginInvoke stuff is necessary.
It then becomes a design decision on how to partition the work; I prefer to use
lightweight methods that do multiple control access at once on the UI thread, so I call
them (with Invoke) when I need them, rather than doing the Invoke stuff for every
individual control access. It goes together with structuring your code anyway...

Smile | :)




Luc Pattyn

GeneralRe: Manipulating controls in C#2005 Pin
Mr.Sam9-Jan-07 2:19
Mr.Sam9-Jan-07 2:19 
GeneralRe: Manipulating controls in C#2005 Pin
Luc Pattyn9-Jan-07 2:38
sitebuilderLuc Pattyn9-Jan-07 2:38 
GeneralRe: Manipulating controls in C#2005 Pin
Mr.Sam9-Jan-07 2:51
Mr.Sam9-Jan-07 2:51 
GeneralRe: Manipulating controls in C#2005 Pin
Luc Pattyn9-Jan-07 4:05
sitebuilderLuc Pattyn9-Jan-07 4:05 
QuestionContextSwitchDeadlock Pin
Nooie8-Jan-07 21:46
Nooie8-Jan-07 21:46 
AnswerRe: ContextSwitchDeadlock Pin
Stefan Troschuetz8-Jan-07 22:29
Stefan Troschuetz8-Jan-07 22:29 
GeneralRe: ContextSwitchDeadlock Pin
Nooie8-Jan-07 22:38
Nooie8-Jan-07 22:38 
AnswerRe: ContextSwitchDeadlock Pin
Nooie9-Jan-07 17:41
Nooie9-Jan-07 17:41 
QuestionDevExpress ApplicationMenu - Status Ba Pin
John S Mangam8-Jan-07 21:32
John S Mangam8-Jan-07 21:32 
AnswerRe: DevExpress ApplicationMenu - Status Ba Pin
Pete O'Hanlon8-Jan-07 23:09
mvePete O'Hanlon8-Jan-07 23:09 
GeneralRe: DevExpress ApplicationMenu - Status Ba Pin
John S Mangam9-Jan-07 0:45
John S Mangam9-Jan-07 0:45 
QuestionDevExpress ApplicationMenu - Status Ba Pin
John S Mangam8-Jan-07 21:28
John S Mangam8-Jan-07 21:28 
QuestionSetSystemTime Return Parameters Pin
Tyler458-Jan-07 20:52
Tyler458-Jan-07 20:52 
AnswerRe: SetSystemTime Return Parameters Pin
Mircea Puiu8-Jan-07 22:35
Mircea Puiu8-Jan-07 22:35 
QuestionRe: SetSystemTime Return Parameters Pin
alefaga8-May-09 4:56
alefaga8-May-09 4:56 
AnswerRe: SetSystemTime Return Parameters Pin
Tyler458-May-09 4:59
Tyler458-May-09 4:59 
QuestionSending Email in .Net 2.0 Pin
Sarika Wake8-Jan-07 20:35
Sarika Wake8-Jan-07 20:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.