mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-22 20:55:52 +12:00
Begin work on Unit Tests
This commit is contained in:
parent
cf7605c6c9
commit
eaf1db1ee1
51 changed files with 3883 additions and 2101 deletions
|
@ -1,27 +1,27 @@
|
|||
using System.Threading;
|
||||
|
||||
namespace HISP.Security
|
||||
{
|
||||
public class RandomID
|
||||
{
|
||||
private static Mutex rndmIdMutex = new Mutex();
|
||||
private static int prevId = 0;
|
||||
public static int NextRandomId(int randomId=-1)
|
||||
{
|
||||
int rndmId = 0;
|
||||
rndmIdMutex.WaitOne();
|
||||
|
||||
if (randomId == -1)
|
||||
rndmId = prevId+1;
|
||||
else
|
||||
rndmId = randomId;
|
||||
|
||||
if (rndmId >= prevId)
|
||||
namespace HISP.Security
|
||||
{
|
||||
public class RandomID
|
||||
{
|
||||
private static Mutex rndmIdMutex = new Mutex();
|
||||
private static int prevId = 0;
|
||||
public static int NextRandomId(int randomId=-1)
|
||||
{
|
||||
int rndmId = 0;
|
||||
rndmIdMutex.WaitOne();
|
||||
|
||||
if (randomId == -1)
|
||||
rndmId = prevId+1;
|
||||
else
|
||||
rndmId = randomId;
|
||||
|
||||
if (rndmId >= prevId)
|
||||
prevId = rndmId;
|
||||
|
||||
rndmIdMutex.ReleaseMutex();
|
||||
|
||||
return rndmId;
|
||||
}
|
||||
}
|
||||
}
|
||||
rndmIdMutex.ReleaseMutex();
|
||||
|
||||
return rndmId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue