You need to provide thread-safe access through accessor functions to an internal member variable.
public static class SaferMemberAccess
{
private static int _numericField = 1;
private static object _syncObj = new object( );
public static void IncrementNumericField( )
{
lock (_syncObj)
{
++_numericField;
}
}
public static void ModifyNumericField(int newValue)
{
lock (_syncObj)
{
_numericField = newValue;
}
}
public static int ReadNumericField( )
{
lock (_syncObj)
{
return (_numericField);
}
}
}