C# Class RandomOps.RandomDotOrgAsync

Similar to the RandomDotOrg-class, only this uses asynchronous retrieval of the random bytes, which is preferrable in time-critical applications. If bytes are not available in the downloaded buffer, then a thread is woken up to fill the buffer. In the meantime a Fallback RNG is used instead. Not thread-safe.
Be sure to call Dispose() after you are done using this RNG, so the worker-thread can be shut down properly. Also note that this class is not thread-safe with regard to multiple threads calling e.g. the Uniform() method simultaneously. To make it thread-safe in this manner, wrap it in a ThreadSafe-object.
Inheritance: ByteStreamAsync
Afficher le fichier Open project: DanWBR/dwsim3

Méthodes publiques

Méthode Description
RandomDotOrgAsync ( int bufferSize, int retrieveTrigger, Random randFallback, int numFallback ) : System.Collections.Generic

Constructs the RNG-object.

Méthodes protégées

Méthode Description
DoFillBuffer ( int length ) : void

Called from ByteStream to request the retrieval of random bytes.

Method Details

DoFillBuffer() protected final méthode

Called from ByteStream to request the retrieval of random bytes.
protected final DoFillBuffer ( int length ) : void
length int The number of bytes requested.
Résultat void

RandomDotOrgAsync() public méthode

Constructs the RNG-object.
public RandomDotOrgAsync ( int bufferSize, int retrieveTrigger, Random randFallback, int numFallback ) : System.Collections.Generic
bufferSize int Number of random bytes the buffer holds.
retrieveTrigger int Refill buffer asynchronously when its size falls below this.
randFallback Random Fallback RNG to be used when buffer is empty.
numFallback int Use fallback RNG for this many bytes before trying to fill buffer again.
Résultat System.Collections.Generic