Click here to Skip to main content
15,886,077 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to change the background color of a selected row in datagridview Pin
OriginalGriff31-Jan-13 22:46
mveOriginalGriff31-Jan-13 22:46 
AnswerRe: how to change the background color of a selected row in datagridview Pin
Richard MacCutchan31-Jan-13 22:38
mveRichard MacCutchan31-Jan-13 22:38 
GeneralRe: how to change the background color of a selected row in datagridview Pin
NarVish31-Jan-13 22:45
NarVish31-Jan-13 22:45 
QuestionHow to write events in event log using Log4net Pin
venkatpappu31-Jan-13 21:28
venkatpappu31-Jan-13 21:28 
AnswerRe: How to write events in event log using Log4net Pin
Richard MacCutchan31-Jan-13 22:11
mveRichard MacCutchan31-Jan-13 22:11 
QuestionThread.Abort - using and lock statement Pin
devvvy31-Jan-13 15:49
devvvy31-Jan-13 15:49 
AnswerRe: Thread.Abort - using and lock statement Pin
Dave Kreskowiak31-Jan-13 17:53
mveDave Kreskowiak31-Jan-13 17:53 
GeneralRe: Thread.Abort - using and lock statement Pin
devvvy31-Jan-13 17:59
devvvy31-Jan-13 17:59 
Dave Kreskowiak wrote:
The same as usually.

I don't like "Usually" ...
I read from somewhere that [^]lock(x) statement is syntactic sugar, that JIT compiler will autogenerate the following:
<br />
Monitor.Enter(o);<br />
S0;<br />
try {<br />
    S1;<br />
} finally {<br />
    Monitor.Exit(o);<br />
}<br />

However, for some compiler architecture, your code will not cleanup properly if Thread.Abort called at point "S0" above before the generated try block, thus Monitor.Exit will not be exited.
But hold - I just found out the answer - I missed the update from the referenced post which says M$ corrected the problem:
<br />
Update 4/17/08: This was indeed fixed for the X64 JIT in Visual Studio 2008.  Note that when compiling C# code targeting both X86 and X64, if you do not use the /o+ switch, this problem can still occur due to extra explicit NOPs inserted before the try.<br />
<br />
The framework implements a method Monitor.ReliableEnter, by the way, that could be used to avoid orphaning locks in the face of thread aborts, but it's internal to mscorlib.dll.  It sets an out parameter within a region of code that cannot be interrupted by a thread abort, which the caller can then check inside the finally block.  The acquisition then gets moved inside so that, if the CALL is reached, the finally block is guaranteed to always run.  You'd then write this instead:<br />
<br />
    bool taken;<br />
    try {<br />
        Monitor.ReliableEnter(o, out taken);<br />
        S1;<br />
    } finally {<br />
        if (taken)<br />
            Monitor.Exit(o);<br />
    }<br />


Problem solved!
dev


modified 1-Feb-13 0:09am.

GeneralRe: Thread.Abort - using and lock statement Pin
Dave Kreskowiak31-Jan-13 19:05
mveDave Kreskowiak31-Jan-13 19:05 
GeneralRe: Thread.Abort - using and lock statement Pin
devvvy31-Jan-13 19:07
devvvy31-Jan-13 19:07 
GeneralRe: Thread.Abort - using and lock statement Pin
devvvy6-Nov-13 17:13
devvvy6-Nov-13 17:13 
Questionbuild C# as windows app Pin
dcof31-Jan-13 12:12
dcof31-Jan-13 12:12 
AnswerRe: build C# as windows app Pin
Mycroft Holmes31-Jan-13 13:51
professionalMycroft Holmes31-Jan-13 13:51 
AnswerRe: build C# as windows app Pin
Dave Kreskowiak31-Jan-13 14:53
mveDave Kreskowiak31-Jan-13 14:53 
AnswerRe: build C# as windows app Pin
Abhinav S31-Jan-13 22:37
Abhinav S31-Jan-13 22:37 
AnswerRe: build C# as windows app Pin
Pete O'Hanlon31-Jan-13 23:40
mvePete O'Hanlon31-Jan-13 23:40 
QuestionC# and ADP (Automatic Data Processing) integration Pin
Dan_YYC31-Jan-13 5:18
Dan_YYC31-Jan-13 5:18 
AnswerRe: C# and ADP (Automatic Data Processing) integration Pin
Dan_YYC4-Feb-13 3:56
Dan_YYC4-Feb-13 3:56 
QuestionAuto relocate a label Pin
justcop31-Jan-13 4:41
justcop31-Jan-13 4:41 
AnswerRe: Auto relocate a label Pin
Abhinav S31-Jan-13 6:13
Abhinav S31-Jan-13 6:13 
AnswerRe: Auto relocate a label Pin
Dave Kreskowiak31-Jan-13 7:02
mveDave Kreskowiak31-Jan-13 7:02 
AnswerRe: Auto relocate a label Pin
Eddy Vluggen31-Jan-13 10:22
professionalEddy Vluggen31-Jan-13 10:22 
QuestionUpload files over HTTPS Pin
Edis Husic31-Jan-13 1:37
Edis Husic31-Jan-13 1:37 
QuestionADAM LDAP Authentification via user distinguishedName Pin
mappy7501730-Jan-13 22:41
mappy7501730-Jan-13 22:41 
QuestionSubreport Pin
theezin30-Jan-13 22:16
theezin30-Jan-13 22:16 

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.