You do indeed have a race condition. This is because you are locking Me, so each object is locking itself, not some shared object. So:
1) Don't use
MethodImplOptions.Synchronized
- ever!
2) Don't use
SyncLock Me
- ever!
3) Add a shared object to
Scrambler
:
Private Shared _Lock As New Object()<br />
<br />
4) In the <code>Random
method, use:
SyncLock _Lock
Note: I don't do VB, so you might have to fix the syntax.
Nick