public byte[] GenerateSeed(
int numBytes,
bool fast)
{
this.counter = 0;
this.stop = false;
byte[] result = new byte[numBytes];
int last = 0;
int end = fast ? numBytes : numBytes * 8;
ThreadPool.QueueUserWorkItem(new WaitCallback(Run));
for (int i = 0; i < end; i++)
{
while (this.counter == last)
{
try
{
Thread.Sleep(1);
}
catch (Exception)
{
// ignore
}
}
last = this.counter;
if (fast)
{
result[i] = (byte) last;
}
else
{
int bytepos = i / 8;
result[bytepos] = (byte) ((result[bytepos] << 1) | (last & 1));
}
}
this.stop = true;
return result;
}