Click here to Skip to main content
15,916,702 members
Home / Discussions / C#
   

C#

 
QuestionHow to know if Word is running under Outlook in Add-in Pin
zhihongwang3-Aug-06 9:15
zhihongwang3-Aug-06 9:15 
Questiona little further with System.Threading.Interlocked class Pin
mikewinny3-Aug-06 8:58
mikewinny3-Aug-06 8:58 
ok so perhaps not c# specific but its the language im using so...
i have some (hopefully) thread-safe code that accesses some shared fields using the lock statement but im trying to avoid full-on locking.
i need to update a field only if the result does not exceed some other value.
i found the following code for simple value update (in the CompareExchange() example):
do {
   initialValue = totalValue;
   computedValue = initialValue + addend;
} while (initialValue != Interlocked.CompareExchange(ref totalValue, computedValue, initialValue));

now, if i use the following would it be properly thread-safe and do wot i need..?
do {
   initialValue = originalValue;
   result = initialValue + addValue;
   overFlag = result > maxValue;
   if (overFlag) result = initialValue;
} while (initialValue != Interlocked.CompareExchange(ref originalValue, result, initialValue));

overFlag is bool and would be used after the udpate code to determine whether to continue or not.
i cant quite get my head around it. Confused | :confused:

thanks in advance


I worship his divine shadow.

QuestionHow to reorder ToolStripMenuItems in a MenuStrip Programmatically? Pin
glima3-Aug-06 6:53
glima3-Aug-06 6:53 
AnswerRe: How to reorder ToolStripMenuItems in a MenuStrip Programmatically? Pin
Judah Gabriel Himango3-Aug-06 8:48
sponsorJudah Gabriel Himango3-Aug-06 8:48 
GeneralRe: How to reorder ToolStripMenuItems in a MenuStrip Programmatically? Pin
glima3-Aug-06 10:23
glima3-Aug-06 10:23 
GeneralRe: How to reorder ToolStripMenuItems in a MenuStrip Programmatically? Pin
glima3-Aug-06 10:28
glima3-Aug-06 10:28 
GeneralRe: How to reorder ToolStripMenuItems in a MenuStrip Programmatically? Pin
Stefan Troschuetz3-Aug-06 10:36
Stefan Troschuetz3-Aug-06 10:36 
QuestionA source (example) to do... Help ! Pin
bttf3-Aug-06 6:50
bttf3-Aug-06 6:50 
AnswerRe: A source (example) to do... Help ! Pin
Not Active3-Aug-06 7:40
mentorNot Active3-Aug-06 7:40 
GeneralRe: A source (example) to do... Help ! Pin
bttf5-Aug-06 21:47
bttf5-Aug-06 21:47 
GeneralRe: A source (example) to do... Help ! Pin
bttf7-Aug-06 8:53
bttf7-Aug-06 8:53 
QuestionA Little Problem in Single Instance Implementaion!!! Pin
RizwanSharp3-Aug-06 6:40
RizwanSharp3-Aug-06 6:40 
JokeRe: A Little Problem in Single Instance Implementaion!!! Pin
Not Active3-Aug-06 7:44
mentorNot Active3-Aug-06 7:44 
GeneralRe: A Little Problem in Single Instance Implementaion!!! Pin
RizwanSharp3-Aug-06 7:47
RizwanSharp3-Aug-06 7:47 
AnswerRe: A Little Problem in Single Instance Implementaion!!! Pin
Josh Smith3-Aug-06 8:49
Josh Smith3-Aug-06 8:49 
GeneralRe: A Little Problem in Single Instance Implementaion!!! Pin
RizwanSharp3-Aug-06 19:36
RizwanSharp3-Aug-06 19:36 
QuestionGetting the installation directory in a Deployment project Pin
GazzaJ3-Aug-06 6:31
GazzaJ3-Aug-06 6:31 
QuestionStrange Problem Regarding TabIndex Pin
RizwanSharp3-Aug-06 6:22
RizwanSharp3-Aug-06 6:22 
AnswerRe: Strange Problem Regarding TabIndex Pin
Ingo3-Aug-06 6:35
Ingo3-Aug-06 6:35 
GeneralRe: Strange Problem Regarding TabIndex Pin
RizwanSharp3-Aug-06 6:46
RizwanSharp3-Aug-06 6:46 
GeneralRe: Strange Problem Regarding TabIndex Pin
RizwanSharp3-Aug-06 6:57
RizwanSharp3-Aug-06 6:57 
GeneralRe: Strange Problem Regarding TabIndex Pin
Ingo3-Aug-06 8:18
Ingo3-Aug-06 8:18 
GeneralRe: Strange Problem Regarding TabIndex Pin
RizwanSharp3-Aug-06 19:40
RizwanSharp3-Aug-06 19:40 
GeneralRe: Strange Problem Regarding TabIndex Pin
Ingo3-Aug-06 22:13
Ingo3-Aug-06 22:13 
AnswerRe: Strange Problem Regarding TabIndex Pin
Paul Brower3-Aug-06 10:42
Paul Brower3-Aug-06 10:42 

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.