G
Guest
Hi,
I have several threads that write to the same int. Each thread increment the
integer value. What is the simple way to synchronize the increment operation.
The lock statement works only on Object so i can't use it. I tried also the
following:
private void incSimpleType(ref int n)
{
Monitor.Enter(n);
n+= 1;
Monitor.Exit(n);
}
It gives me the following error:
Object synchronization method was called from an unsynchronized block of code.
Please help me.
Thanks!
I have several threads that write to the same int. Each thread increment the
integer value. What is the simple way to synchronize the increment operation.
The lock statement works only on Object so i can't use it. I tried also the
following:
private void incSimpleType(ref int n)
{
Monitor.Enter(n);
n+= 1;
Monitor.Exit(n);
}
It gives me the following error:
Object synchronization method was called from an unsynchronized block of code.
Please help me.
Thanks!