namespace Mirle.Component.API.AutomatedGuideVehicleController.Entities { /// /// Class for message sequnce number /// public class MessageSequnce { /// /// Constructure /// protected MessageSequnce() { _sequence = 0; } #region === [Private Properties] === /// /// Message sequnce number /// private static volatile MessageSequnce _messageSequnce; /// /// Lock of message sequnce number /// private static readonly object _syncRoot = new object(); /// /// Sequnce number /// private int _sequence; /// /// Lock of get sequnce number /// private static readonly object _messageLock = new object(); #endregion /// /// Message Sequnce instance /// public static MessageSequnce Instance { get { lock (_syncRoot) { _messageSequnce ??= new MessageSequnce(); return _messageSequnce; } } } /// /// Message sequnce number /// public string Sequence { get { lock (_messageLock) { if (_sequence == 0 || _sequence == 999999) { _sequence = 1; } else { _sequence++; } return _sequence.ToString().PadLeft(6, '0'); } } } } }