Click here to Skip to main content
15,887,175 members
Home / Discussions / C#
   

C#

 
AnswerRe: Add login form to a program? Pin
carbon_golem5-May-08 6:51
carbon_golem5-May-08 6:51 
Questionhow I know that which property is associated which file at run time. Pin
Guru Call5-May-08 4:47
Guru Call5-May-08 4:47 
QuestionRunning a form in a diferent Thread Pin
oscarderooij5-May-08 4:07
oscarderooij5-May-08 4:07 
AnswerRe: Running a form in a diferent Thread Pin
S. Senthil Kumar5-May-08 5:34
S. Senthil Kumar5-May-08 5:34 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij6-May-08 2:29
oscarderooij6-May-08 2:29 
GeneralRe: Running a form in a diferent Thread Pin
S. Senthil Kumar6-May-08 2:54
S. Senthil Kumar6-May-08 2:54 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij13-May-08 3:27
oscarderooij13-May-08 3:27 
AnswerRe: Running a form in a diferent Thread Pin
Luc Pattyn5-May-08 7:19
sitebuilderLuc Pattyn5-May-08 7:19 
Hi,

you should not try and run drawing code in a thread other than the main thread (aka
GUI thread). Instead you should use one or more additional threads to do the slow stuff
(computations, database access, network communication, etc) and from time to time
ask the main thread to adapt the GUI.

You can achieve this in many ways, including:
- explicit instances of the Thread class (good control of what runs when, at which
priority, etc)
- threads from the ThreadPool (less control);
- instances of BackgroundWorker class (it offers a ReportProgress method that
automatically runs on the main thread).

That is the theory. In practice, on top of the above, you'd better group the GUI updates
to avoid many small updates, instead group them (e.g. using a List) and have them execute
periodically. This results in:
- fewer thread switching, hence better performance;
- when organized correctly (e.g. Control.SuspendLayout), better performance and better
visual experience;
- possibly cleaner code.

Grouping updates can be done based on a counter, a timer, or whatever suits the application.


Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

I dislike the black-and-white voting system on questions/answers. Dead | X|


GeneralRe: Running a form in a diferent Thread Pin
oscarderooij6-May-08 2:42
oscarderooij6-May-08 2:42 
GeneralRe: Running a form in a diferent Thread Pin
Luc Pattyn6-May-08 4:21
sitebuilderLuc Pattyn6-May-08 4:21 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij13-May-08 3:25
oscarderooij13-May-08 3:25 
GeneralRe: Running a form in a diferent Thread Pin
Luc Pattyn13-May-08 3:45
sitebuilderLuc Pattyn13-May-08 3:45 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij13-May-08 3:28
oscarderooij13-May-08 3:28 
GeneralRe: Running a form in a diferent Thread Pin
Luc Pattyn13-May-08 3:40
sitebuilderLuc Pattyn13-May-08 3:40 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij15-May-08 7:45
oscarderooij15-May-08 7:45 
QuestionForeach property in myClass Pin
Harvey Saayman5-May-08 3:57
Harvey Saayman5-May-08 3:57 
AnswerRe: Foreach property in myClass Pin
Colin Angus Mackay5-May-08 4:04
Colin Angus Mackay5-May-08 4:04 
AnswerRe: Foreach property in myClass Pin
S. Senthil Kumar5-May-08 4:06
S. Senthil Kumar5-May-08 4:06 
GeneralRe: Foreach property in myClass Pin
Harvey Saayman5-May-08 4:12
Harvey Saayman5-May-08 4:12 
GeneralRe: Foreach property in myClass Pin
carbon_golem5-May-08 5:01
carbon_golem5-May-08 5:01 
GeneralRe: Foreach property in myClass Pin
Nouman Bhatti5-May-08 4:07
Nouman Bhatti5-May-08 4:07 
AnswerRe: Foreach property in myClass Pin
Yevgen Lisovenko5-May-08 4:07
Yevgen Lisovenko5-May-08 4:07 
AnswerRe: Foreach property in myClass Pin
Ennis Ray Lynch, Jr.5-May-08 10:30
Ennis Ray Lynch, Jr.5-May-08 10:30 
QuestionCrystal Reports Pin
GermanDM5-May-08 3:51
GermanDM5-May-08 3:51 
QuestionPass DataGridView to a UserControl Pin
mariusth5-May-08 3:51
mariusth5-May-08 3:51 

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.