Code: Select all
public uint NextSequenceNumber()
{
lock (_syncSequenceNumber)
{
//Changed 0x7FFFFFFF to int.MaxValue for easy representation only
if (_counter == int.MaxValue)
_counter = 0;
//Return from within the lock body as value may get change by another thread before the call of return statement
//_counter++;
return ++_counter;
}
//No longer needed
//return _counter;
}
public byte NextReferenceNumber()
{
lock (_syncReferenceNumber)
{
if (_byteCounter == byte.MaxValue)
_byteCounter = 0;
//Return from within the lock body as value may get change by another thread before the call of return statement
//_byteCounter++;
return ++_byteCounter;
}
//No longer needed
//return _byteCounter;
}