Click here to Skip to main content
15,889,815 members
Home / Discussions / C#
   

C#

 
QuestionRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178015-Feb-10 10:23
User 680178015-Feb-10 10:23 
AnswerRe: Cross-Threading problem, InvokeRequired and Events Pin
Luc Pattyn15-Feb-10 10:32
sitebuilderLuc Pattyn15-Feb-10 10:32 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178015-Feb-10 10:38
User 680178015-Feb-10 10:38 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Luc Pattyn15-Feb-10 11:30
sitebuilderLuc Pattyn15-Feb-10 11:30 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178015-Feb-10 10:45
User 680178015-Feb-10 10:45 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Luc Pattyn15-Feb-10 11:23
sitebuilderLuc Pattyn15-Feb-10 11:23 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Daniel Grunwald16-Feb-10 8:41
Daniel Grunwald16-Feb-10 8:41 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Luc Pattyn16-Feb-10 9:06
sitebuilderLuc Pattyn16-Feb-10 9:06 
Thanks, that is very informative.

1.
It is too bad MSDN didn't provide the clue; rather than just saying "[AppendText:] You can use this method to add text to the existing text in the control instead of using the concatenation operator (+) to concatenate text to the Text property." it should have mentioned performance reasons for using AppendText().

2.
I understand your timer+StringBuilder+lock approach is more performant, it also is more complex, and typically will result in some extra latency, which makes it harder to use to diagnose fatal crashes where one wants to see the most recent messages available. For logging I tend to prefer synchronous operations without extra latency, even when that reduces overall performance a bit; a ListBox and Control.Invoke serve me well. But I will experiment with what you suggested.

3.
When using the InvokeRequired/Invoke pattern, I hesitate to use Control.BeginInvoke() as that modifies the semantics of the method: when on the right thread, it works synchronously, whereas on another thread it only executes asynchronously. I am aware the thread switches are expensive though.


I may conduct several experiments on all this and create a little article on the subject.
Again, thanks.

Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]

I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.

GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Daniel Grunwald16-Feb-10 9:26
Daniel Grunwald16-Feb-10 9:26 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178016-Feb-10 9:42
User 680178016-Feb-10 9:42 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Daniel Grunwald16-Feb-10 9:49
Daniel Grunwald16-Feb-10 9:49 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178016-Feb-10 9:52
User 680178016-Feb-10 9:52 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Daniel Grunwald16-Feb-10 9:59
Daniel Grunwald16-Feb-10 9:59 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178016-Feb-10 10:31
User 680178016-Feb-10 10:31 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Daniel Grunwald16-Feb-10 8:45
Daniel Grunwald16-Feb-10 8:45 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178016-Feb-10 9:08
User 680178016-Feb-10 9:08 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Daniel Grunwald16-Feb-10 9:39
Daniel Grunwald16-Feb-10 9:39 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
Luc Pattyn16-Feb-10 9:45
sitebuilderLuc Pattyn16-Feb-10 9:45 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178016-Feb-10 10:02
User 680178016-Feb-10 10:02 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178016-Feb-10 10:09
User 680178016-Feb-10 10:09 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178017-Feb-10 7:05
User 680178017-Feb-10 7:05 
AnswerRe: Cross-Threading problem, InvokeRequired and Events Pin
#realJSOP15-Feb-10 23:21
mve#realJSOP15-Feb-10 23:21 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178019-Feb-10 4:10
User 680178019-Feb-10 4:10 
GeneralRe: Cross-Threading problem, InvokeRequired and Events Pin
User 680178019-Feb-10 8:06
User 680178019-Feb-10 8:06 
QuestionC# TableLayoutPanel MouseLeave Pin
ikurtz15-Feb-10 5:27
ikurtz15-Feb-10 5:27 

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.