System.Threading.Tasks并发和异步代码使用
main.cs
System.Threading.Tasks.Parallel.For(0, 10, i =>
{
TestLock testLock = RedisBillLockWrapper.Wrap<TestLock>(new TestLock());
testLock.Run();
});
Console.Read();
testlock.cs
class TestLock : MarshalByRefObject
{
[RedisBillLock("127.0.0.1", "memcache_lock_service_key_test")]
public void Run()
{
Console.WriteLine("{0:yyyyMMddHHmmssfff}获取了锁", DateTime.Now);
Thread.Sleep(1000);
}
}