Click here to Skip to main content
15,911,360 members
Home / Discussions / C#
   

C#

 
QuestionAutocomplete -> BindingSource -> Position change Pin
Glen Harvy13-Jan-07 14:09
Glen Harvy13-Jan-07 14:09 
QuestionSetting a default value for a datagridviewtextbox column Pin
bluewavestrider13-Jan-07 12:07
bluewavestrider13-Jan-07 12:07 
AnswerRe: Setting a default value for a datagridviewtextbox column Pin
Lisa Jorgensen13-Jan-07 15:14
Lisa Jorgensen13-Jan-07 15:14 
GeneralRe: Setting a default value for a datagridviewtextbox column Pin
bluewavestrider14-Jan-07 4:45
bluewavestrider14-Jan-07 4:45 
Questionhow to read status registers of parallel port Pin
George-Lucian13-Jan-07 11:44
George-Lucian13-Jan-07 11:44 
AnswerRe: how to read status registers of parallel port Pin
Phillip M. Hoff13-Jan-07 11:59
Phillip M. Hoff13-Jan-07 11:59 
QuestionA multithreading "best practice" question! Pin
Nader Elshehabi13-Jan-07 10:58
Nader Elshehabi13-Jan-07 10:58 
AnswerRe: A multithreading "best practice" question! Pin
Phillip M. Hoff13-Jan-07 11:38
Phillip M. Hoff13-Jan-07 11:38 
1. I don't have a direct comparison, but 2-3 minutes to create a 30,000 node TreeView seems slow. I think your performance problem is due to two things: making individual TreeView updates and making those updates via individual BeginInvoke() calls. On my 1.63GHz Core2 Duo, it takes about 45 seconds when updates are performed individually from within a loop on the UI thread. When batching the updates, that time was cut down to 20 seconds.

Using Control.Invoke() or Control.BeginInvoke() is a relatively expensive operation due to all of the coordination necessary to shift to and execute the delegate on the UI thread. While it's necessary in order to update the UI from a worker thread, it should not be used in "tight loop" situations. Instead, one should make a single Invoke()/BeginInvoke() call and make *all* the updates from within that single delegate.

This model also allows one to make use of the Control.BeginUpdate() and Control.EndUpdate() methods. These disable and reenable drawing of the control. By adding your new nodes in between those method calls, the system will add them without repeatedly refreshing the control display, and therefore, will add them more quickly.

2. You're likely seeing the UI freeze due to your Thread.Sleep(1) in your PopulateList() method. If this is being called on the UI thread, it effectivly stops the Windows message pump until the thread exits. Blocking on the UI thread is strongly discouraged. If your thread is also interacting with the message pump (e.g. by making Control.Invoke() calls), you could also be setting up a deadlock situation.

One trick to prevent the "impatient user multiple-click" is to disable the button on the first click and only reenable it once the resulting action is complete.

-Phil
GeneralRe: A multithreading "best practice" question! Pin
Nader Elshehabi13-Jan-07 12:28
Nader Elshehabi13-Jan-07 12:28 
GeneralRe: A multithreading "best practice" question! Pin
Phillip M. Hoff13-Jan-07 14:25
Phillip M. Hoff13-Jan-07 14:25 
GeneralRe: A multithreading "best practice" question! Pin
Nader Elshehabi14-Jan-07 9:02
Nader Elshehabi14-Jan-07 9:02 
QuestionXNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Software_Specialist13-Jan-07 10:48
Software_Specialist13-Jan-07 10:48 
AnswerRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Nader Elshehabi13-Jan-07 11:12
Nader Elshehabi13-Jan-07 11:12 
GeneralRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Software_Specialist13-Jan-07 11:31
Software_Specialist13-Jan-07 11:31 
GeneralRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Nader Elshehabi13-Jan-07 12:05
Nader Elshehabi13-Jan-07 12:05 
AnswerRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Colin Angus Mackay13-Jan-07 11:39
Colin Angus Mackay13-Jan-07 11:39 
GeneralRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Software_Specialist13-Jan-07 12:07
Software_Specialist13-Jan-07 12:07 
QuestionRead Excel file and create another file met some part of first excel file [modified] Pin
teymur_khan13-Jan-07 10:05
teymur_khan13-Jan-07 10:05 
AnswerRe: Read Excel file and create another file met some part of first excel file Pin
Phillip M. Hoff13-Jan-07 11:50
Phillip M. Hoff13-Jan-07 11:50 
GeneralRe: Read Excel file and create another file met some part of first excel file Pin
teymur_khan14-Jan-07 5:14
teymur_khan14-Jan-07 5:14 
Questionhow to manage Device(s) from USB port ? Pin
hdv21213-Jan-07 9:28
hdv21213-Jan-07 9:28 
AnswerRe: how to manage Device(s) from USB port ? Pin
Nader Elshehabi13-Jan-07 10:41
Nader Elshehabi13-Jan-07 10:41 
QuestionAccessing resource on unknown CD-ROM (drive letter). Pin
TrooperIronMan13-Jan-07 9:09
TrooperIronMan13-Jan-07 9:09 
AnswerRe: Accessing resource on unknown CD-ROM (drive letter). Pin
Luc Pattyn13-Jan-07 9:23
sitebuilderLuc Pattyn13-Jan-07 9:23 
GeneralRe: Accessing resource on unknown CD-ROM (drive letter). Pin
TrooperIronMan13-Jan-07 9:47
TrooperIronMan13-Jan-07 9:47 

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.