Uuid80.RandomGenerator

Namespace: System · class

Generates 80-bit UUIDs using a secure random number generator

Remarks

Methods of this type are thread-safe.

Constructors

RandomGenerator

RandomGenerator()

Constructs a new random UUID generator

RandomGenerator(RandomNumberGenerator generator)

Constructs a new random UUID generator, using a specific random number generator

Methods

NewUuid

Uuid80 NewUuid()

Return a new random 80-bit UUID

Returns: Uuid80 that contains 80 bits worth of randomness.

This method needs to acquire a lock. If multiple threads needs to generate ids concurrently, you may need to create an instance of this class for each thread.The uniqueness of the generated uuids depends on the quality of the random number generator. If you cannot tolerate collisions, you either have to check if a newly generated uid already exists, or use a different kind of generator.

Fields

Default

static readonly RandomGenerator Default

Default instance of a random generator

Using this instance will introduce a global lock in your application. You can create specific instances for worker threads, if you require concurrency.