You could store the value in a clr.StrongBox[int] and pass that instead and it should work. The way you're calling increment now it's always passing in the value and returning a tuple of prevValue, newValue.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dan Eloff Sent: Friday, November 14, 2008 9:35 AM To: Discussion of IronPython Subject: Re: [IronPython] Interlocked methods and IronPython ... sometimes. The reason it seems to work is that python integers are immutable and the safe count is always zero :) You could assign back to SafeCount the result of the increment, but the assignment isn't necessarily safe. I guess these kinds of things either need to be written in C#, or use a Monitor or Lock as always in Python. -Dan On Fri, Nov 14, 2008 at 11:18 AM, Dan Eloff <[EMAIL PROTECTED]> wrote: > I've often wondered if the CLR Interlocked methods work with > IronPython. It seems that Interlocked.Increment works fine with module > globals (see attached script.) Whether it works fine in general I > don't know. Does anybody know anything about this? > > -Dan > >>ipy interlockedinc.py > UnsafeCount: -32081 > SafeCount: 0 > >>ipy interlockedinc.py > UnsafeCount: -27749 > SafeCount: 0 > >>ipy interlockedinc.py > UnsafeCount: -37339 > SafeCount: 0 > >>ipy interlockedinc.py > UnsafeCount: -39461 > SafeCount: 0 > >>ipy interlockedinc.py > UnsafeCount: 23175 > SafeCount: 0 > _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
