I’m looking at some code, and I see a line that looks like this:
// 1 if timer is executing, else 0
private int _inTimer;
This appears to be a binary flag. You are either in the timer, or you’re not.
Why would you want to declare this as an int and not a bool?
I can understand the scenario if you eventually want to add different states, but then I would argue using an enum.
You might want to use
intinstead ofboolif you need to use atomic operations such asInterlocked.CompareExchange.PS: I know about
Interlocked.CompareExchange<T>, but it was introduced in .NET 3.5 and supports only reference types.