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

C#

 
AnswerRe: Atomicity in C# Pin
Matt T Heffron16-May-13 12:05
professionalMatt T Heffron16-May-13 12:05 
GeneralRe: Atomicity in C# Pin
gggustafson17-May-13 5:32
mvagggustafson17-May-13 5:32 
GeneralRe: Atomicity in C# Pin
Dave Kreskowiak17-May-13 7:49
mveDave Kreskowiak17-May-13 7:49 
GeneralRe: Atomicity in C# Pin
gggustafson17-May-13 7:59
mvagggustafson17-May-13 7:59 
GeneralRe: Atomicity in C# Pin
Dave Kreskowiak17-May-13 9:40
mveDave Kreskowiak17-May-13 9:40 
GeneralRe: Atomicity in C# Pin
gggustafson17-May-13 10:11
mvagggustafson17-May-13 10:11 
AnswerRe: Atomicity in C# Pin
AspDotNetDev16-May-13 12:02
protectorAspDotNetDev16-May-13 12:02 
GeneralRe: Atomicity in C# Pin
gggustafson17-May-13 6:14
mvagggustafson17-May-13 6:14 
I appreciate your thoughts.

I am fully aware that the text of a program does not affect its runtime behavior. lock is useful in concurrent processes to insure that critical regions are not simultaneously executed by multiple processes.

The reason that I am fiercely opposed to multiple statements on a line is for the same reason that I expect that edge detection be enforced. In an earlier article, Minimalist Coding Guidelines, I give an example of why:
C#
Block   Declaration

  1     [ DllImport ( "gdi32.dll", EntryPoint = "BitBlt" ) ]
        public static extern bool BitBlt ( IntPtr hdcDest, int nXDest,
                                  int nYDest, int nWidth, int nHeight, 
                                  IntPtr hdcSrc, int nXSrc, int nYSrc, 
                                  int dwRop );

  2     [ DllImport ( "gdi32.dll", 
                      EntryPoint = "BitBlt" ) ]
        public static extern bool BitBlt ( IntPtr hdcDest, 
                                           int    nXDest,
                                           int    nYDest, 
                                           int    nWidth, 
                                           int    nHeight, 
                                           IntPtr hdcSrc,
                                           int    nXSrc, 
                                           int    nYSrc, 
                                           int    dwRop );

I don't think that there are those who would claim that the style of Block 1 is superior to that of Block 2.

I'm sorry that I do not agree with your commenting style. A comment that relates to a statement should be placed to the right of the statement, not above it. This coding style makes the comment "part of the statement." Thus if the statement is removed or moved, the comment is removed or moved with it.

I do like the idea of creating a body surrounding the statements.

Thanks for your comments.
Gus Gustafson

GeneralRe: Atomicity in C# Pin
PIEBALDconsult16-May-13 12:18
mvePIEBALDconsult16-May-13 12:18 
GeneralRe: Atomicity in C# Pin
gggustafson17-May-13 6:20
mvagggustafson17-May-13 6:20 
GeneralRe: Atomicity in C# Pin
Matt T Heffron17-May-13 6:48
professionalMatt T Heffron17-May-13 6:48 
AnswerRe: Atomicity in C# Pin
Pete O'Hanlon17-May-13 0:43
mvePete O'Hanlon17-May-13 0:43 
GeneralRe: Atomicity in C# Pin
gggustafson17-May-13 6:34
mvagggustafson17-May-13 6:34 
GeneralRe: Atomicity in C# Pin
PIEBALDconsult17-May-13 6:47
mvePIEBALDconsult17-May-13 6:47 
GeneralRe: Atomicity in C# Pin
gggustafson17-May-13 6:55
mvagggustafson17-May-13 6:55 
QuestionHow do tell if a Forms icon is set to the default Visual Studio Icon or my own icon Pin
MarkB12316-May-13 6:35
MarkB12316-May-13 6:35 
AnswerRe: How do tell if a Forms icon is set to the default Visual Studio Icon or my own icon Pin
Eddy Vluggen16-May-13 7:01
professionalEddy Vluggen16-May-13 7:01 
GeneralRe: How do tell if a Forms icon is set to the default Visual Studio Icon or my own icon Pin
MarkB12316-May-13 7:21
MarkB12316-May-13 7:21 
GeneralRe: How do tell if a Forms icon is set to the default Visual Studio Icon or my own icon Pin
Eddy Vluggen16-May-13 7:30
professionalEddy Vluggen16-May-13 7:30 
GeneralRe: How do tell if a Forms icon is set to the default Visual Studio Icon or my own icon Pin
MarkB12316-May-13 10:16
MarkB12316-May-13 10:16 
GeneralRe: How do tell if a Forms icon is set to the default Visual Studio Icon or my own icon Pin
Eddy Vluggen16-May-13 11:12
professionalEddy Vluggen16-May-13 11:12 
QuestionFill a datagridview using two data sources Pin
geralson15-May-13 23:28
geralson15-May-13 23:28 
AnswerRe: Fill a datagridview using two data sources Pin
Simon_Whale16-May-13 0:11
Simon_Whale16-May-13 0:11 
AnswerRe: Fill a datagridview using two data sources Pin
Eddy Vluggen16-May-13 3:03
professionalEddy Vluggen16-May-13 3:03 
GeneralRe: Fill a datagridview using two data sources Pin
geralson16-May-13 3:52
geralson16-May-13 3:52 

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.