I have a SQL column with datatype as Bigint
, so when I 'm generating a unique number using C# Random class in a multithreaded environment, I see there are duplicate values instead of having unique, I can see only system GUID is the only option to generate unique Id's, could you please help me to solve this problem.
private Object thisLock = new Object();
public Random a = new Random(DateTime.Now.Ticks.GetHashCode());
private void NewNumber()
{
lock (thisLock)
{
MyNumber = a.Next(0, 10);
}
}