[IronPython] Converting C# to Python ... the lock() keyword?
dinov at microsoft.com
Mon Jan 11 19:23:10 CET 2010
If you really want to use .NET monitors you can code it up as a try/finally:
If you'd like to do a slightly more Pythonic lock you could do:
x = threading.Lock()
Or you could combine the two approaches:
from System.Threading import Monitor
def __init__(self, obj):
self.obj = obj
def __exit__(self, *args):
> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of Sandy Walsh
> Sent: Monday, January 11, 2010 9:43 AM
> To: users at lists.ironpython.com
> Subject: [IronPython] Converting C# to Python ... the lock() keyword?
> I'm converting a C# program to IronPython and running into the C# lock()
> command ... what is the equivalent operation in IronPython?
> The C# is like:
> if (...)
More information about the Ironpython-users