Groups | Blog | Home
all groups > visual c > march 2007 >

visual c : lock statement in C++?


Tao
3/27/2007 2:24:29 PM
hi.. Group,

is there any lock statement like C# in managed C++?

thanks

Doug Harrison [MVP]
3/27/2007 3:45:22 PM
[quoted text, click to view]

For VC2005, see:

lock Class
http://msdn2.microsoft.com/en-us/library/ms177085(VS.80).aspx

--
Doug Harrison
David Anton
3/27/2007 9:34:04 PM
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


[quoted text, click to view]
Tom Widmer [VC++ MVP]
3/28/2007 12:00:00 AM
[quoted text, click to view]

You can do much better than that:

<msclr\lock.h>

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

} //destructor of l exits monitor.


AddThis Social Bookmark Button