InterlockedIncrement function

drjackool 956 Reputation points
2023-05-31T16:16:14.9833333+00:00

Hi

in Win32

In multi threaded app if we have a global variable to increment and decrement it, from worker threads if we use InterlockedIncrement function, should also use Critical section lock or we do not need critical section lock?

Thanks

Windows development | Windows API - Win32
0 comments No comments
{count} votes

Accepted answer
  1. David Lowndes 2,640 Reputation points MVP
    2023-05-31T16:29:03.2733333+00:00

    You don't need a CS to guard access the variable being altered via InterlockedIncrement and related APIs.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.