Click here to Skip to main content
15,910,981 members
Home / Discussions / C#
   

C#

 
GeneralRe: Receive Cursor X, Y Positions Pin
M Riaz Bashir27-Mar-08 19:36
M Riaz Bashir27-Mar-08 19:36 
GeneralInfinite level hierarchical data grid code using C# with edit ,update option Pin
pp831926-Mar-08 20:42
pp831926-Mar-08 20:42 
GeneralRe: Infinite level hierarchical data grid code using C# with edit ,update option Pin
Eduard Keilholz26-Mar-08 23:00
Eduard Keilholz26-Mar-08 23:00 
GeneralRe: Infinite level hierarchical data grid code using C# with edit ,update option Pin
pp831927-Mar-08 20:18
pp831927-Mar-08 20:18 
GeneralThread safety Pin
N a v a n e e t h26-Mar-08 20:04
N a v a n e e t h26-Mar-08 20:04 
GeneralRe: Thread safety Pin
Luc Pattyn26-Mar-08 20:55
sitebuilderLuc Pattyn26-Mar-08 20:55 
GeneralRe: Thread safety Pin
N a v a n e e t h26-Mar-08 21:38
N a v a n e e t h26-Mar-08 21:38 
GeneralRe: Thread safety Pin
Luc Pattyn26-Mar-08 22:09
sitebuilderLuc Pattyn26-Mar-08 22:09 
Hi,

your first snippet is OK.
double test is very cheap, and much cheaper than always locking, hence no
performance issues at all.

Your eager execution (second snippet) has one advantage:
it is simpler, less code.

and two disadvantages:
1. it always does the load; that's OK if you always need it, which may or may
not be true;
2. it may execute sooner than required (e.g. by accessing something else in the
same class, hence class load and execution of static code), hence delaying an operation
the user might be waiting for.

It depends entirely on the app itself whether the eager code is fine or not.
I tend not to do eager stuff in the main thread, so overall my preference is
doing this kind of initialization in a background thread, unless it is really needed
early on in the app.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.


GeneralRe: Thread safety Pin
N a v a n e e t h26-Mar-08 22:57
N a v a n e e t h26-Mar-08 22:57 
GeneralRe: Thread safety Pin
Luc Pattyn26-Mar-08 23:16
sitebuilderLuc Pattyn26-Mar-08 23:16 
GeneralRe: Thread safety Pin
N a v a n e e t h27-Mar-08 1:00
N a v a n e e t h27-Mar-08 1:00 
QuestionCustomizing a combo box event Pin
steve_rm26-Mar-08 19:48
steve_rm26-Mar-08 19:48 
GeneralRe: Customizing a combo box event Pin
leppie26-Mar-08 23:32
leppie26-Mar-08 23:32 
QuestionHow do i plot a point in a slanting line Pin
Laddie26-Mar-08 19:25
Laddie26-Mar-08 19:25 
AnswerRe: How do i plot a point in a slanting line Pin
Christian Graus26-Mar-08 19:36
protectorChristian Graus26-Mar-08 19:36 
GeneralRe: How do i plot a point in a slanting line Pin
Laddie26-Mar-08 19:46
Laddie26-Mar-08 19:46 
GeneralRe: How do i plot a point in a slanting line Pin
Christian Graus26-Mar-08 19:56
protectorChristian Graus26-Mar-08 19:56 
GeneralRe: How do i plot a point in a slanting line Pin
Laddie26-Mar-08 20:26
Laddie26-Mar-08 20:26 
GeneralRe: How do i plot a point in a slanting line Pin
Laddie26-Mar-08 20:57
Laddie26-Mar-08 20:57 
GeneralUpdating content only ( not . exe) on local drive Pin
m1n1me26-Mar-08 17:55
m1n1me26-Mar-08 17:55 
GeneralRe: Updating content only ( not . exe) on local drive Pin
Christian Graus26-Mar-08 18:32
protectorChristian Graus26-Mar-08 18:32 
GeneralRe: Updating content only ( not . exe) on local drive Pin
m1n1me26-Mar-08 18:45
m1n1me26-Mar-08 18:45 
GeneralRe: Updating content only ( not . exe) on local drive Pin
Christian Graus26-Mar-08 19:14
protectorChristian Graus26-Mar-08 19:14 
QuestionHow to convert info from a dataset object into combobox? [modified] Pin
cuongmits26-Mar-08 13:59
cuongmits26-Mar-08 13:59 
AnswerRe: How to convert info from a dataset object into combobox? Pin
Christian Graus26-Mar-08 14:03
protectorChristian Graus26-Mar-08 14:03 

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.