2023-04-12 11:53:55 +00:00
|
|
|
|
namespace Utils
|
|
|
|
|
{
|
|
|
|
|
public class NumberSource
|
|
|
|
|
{
|
2024-04-15 05:57:13 +00:00
|
|
|
|
private readonly object @lock = new object();
|
2023-04-12 11:53:55 +00:00
|
|
|
|
private int number;
|
|
|
|
|
|
|
|
|
|
public NumberSource(int start)
|
|
|
|
|
{
|
|
|
|
|
number = start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetNextNumber()
|
|
|
|
|
{
|
2024-04-15 05:57:13 +00:00
|
|
|
|
var n = -1;
|
|
|
|
|
lock (@lock)
|
|
|
|
|
{
|
|
|
|
|
n = number;
|
|
|
|
|
number++;
|
|
|
|
|
}
|
2023-04-12 11:53:55 +00:00
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|