lock statement in C++?

  • Thread starter Thread starter Tao
  • Start date Start date
e.g.,
C#
lock (x)
{
}
C++/CLI:
System::Threading::Monitor::Enter(x);
try
{
}
finally
{
System::Threading::Monitor::Exit(x);
}
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
 
David said:
e.g.,
C#
lock (x)
{
}
C++/CLI:
System::Threading::Monitor::Enter(x);
try
{
}
finally
{
System::Threading::Monitor::Exit(x);
}

You can do much better than that:

<msclr\lock.h>

//...
{
msclr::lock l(x);
//do stuff

} //destructor of l exits monitor.


Tom
 
Back
Top