On Thu, 24 Apr 2008 15:49:35 -0700, parez <ps*****@gmail.comwrote:
GetNextSequenceNumber2 worked for me in a different class..
but now it does not work.. it does not increment..
You'll need to post a concise-but-complete code sample that demonstrates
the problem.
will it not get incremented after the return?
In either version of the method you posted, the variable will be
incremented _before_ the return. In one version, it's incremented before
being evaluated as the return value, and in the other it's incremented
after. But in either case, the variable will have its new value before
control is returned to the caller.
In neither version is there an obvious problem, so whatever is going
wrong, it's in a part of the code you didn't show us. Either the code you
posted isn't actually the code that's generating the sequence numbers, or
you're mistaken about whether it works or not.
The only way for anyone to figure out what's actually going wrong is to
see a complete code example. Making it concise will ensure that someone
will bother looking at it. :)
By the way, for what it's worth, if all you're doing is incrementing a
variable, you may find the Interlocked class a better solution than using
the lock() statement. Not that there's anything wrong with using lock()
per se; just that you might prefer the alternative.
Pete