mercredi 5 octobre 2016

Empty byte array when using NextBytes

Consider I have the following code:

public sealed class SimpleRandomProvider : IRandomProvider
{
    private static readonly Lazy<Random> RandomHolder = new Lazy<Random>(() => new Random());

    public void NextBytes(byte[] buffer)
    {
        RandomHolder.Value.NextBytes(buffer);
    }
}

Unfortunately, everytime I call NextBytes in System.Random buffer gets filled with empty bytes:

Screen cast

What is strange, first X (about 100) calls of NextBytes works just fine.

What is happening? May it be a bug in .Net Core?




Aucun commentaire:

Enregistrer un commentaire