An alternative to UBB.threads
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FLocal/Web.Core/Counter.cs

26 lines
426 B

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Web.Core {
public class Counter {
private int value;
private readonly object locker = new object();
public Counter() {
this.value = 0;
}
public int GetCurrentValueAndIncrement() {
lock(this.locker) {
int result = this.value;
this.value++;
return result;
}
}
}
}