Files
2025-05-01 07:20:41 +09:00

36 lines
772 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ServerCore;
//=============================================================================================
// 병렬 프로그래밍 환경에서 특정 로직이 동시에 실행되지 않도록 Monitor를 활용하여 보호하는 클래스 이다.
//
// author : kangms
//
//=============================================================================================
public class AutoLock : IDisposable
{
private readonly object m_lock;
public AutoLock(object tolockObject)
{
m_lock = tolockObject;
Monitor.Enter(m_lock);
}
public void Dispose()
{
Monitor.Exit(m_lock);
}
}