C
Curious
Hi,
I have a datastructure that sorts elements by a key. Now in some
circumstances a key may occur twice and so I would like to change the
old key value by adding 1.
To do this I am doing it recursively within a lock statement. My
problem is that since the myQueue is already locked, if the method is
called again recursively, should it block on the lock statement till
the lock is released?
public void Postpone(key)
{
lock(myQueue)
{
object = myQueue.Remove(key);
try
{
myQueue.Add(object, key+1);
}
catch(Exception)
{
Postpone(key+1);
}
}
}
Can somone help me out
Thanks in Advance
I have a datastructure that sorts elements by a key. Now in some
circumstances a key may occur twice and so I would like to change the
old key value by adding 1.
To do this I am doing it recursively within a lock statement. My
problem is that since the myQueue is already locked, if the method is
called again recursively, should it block on the lock statement till
the lock is released?
public void Postpone(key)
{
lock(myQueue)
{
object = myQueue.Remove(key);
try
{
myQueue.Add(object, key+1);
}
catch(Exception)
{
Postpone(key+1);
}
}
}
Can somone help me out
Thanks in Advance