C
Clive Dixon
Are there any issues I should be worried about when using C# 2.0 iterators
in conjunction with lock, i.e.
public IEnumerator GetEnumerator()
{
lock (lockObject)
{
foreach (object obj in collection)
{
yield return obj;
}
}
}
When precisely is the lock/unlock happening with respect to the iteration?
Lock & unlock once only when the iterator object is created? Lock & unlock
with each iteration? Lock before first iteration & unlock on disposal after
last iteration?
in conjunction with lock, i.e.
public IEnumerator GetEnumerator()
{
lock (lockObject)
{
foreach (object obj in collection)
{
yield return obj;
}
}
}
When precisely is the lock/unlock happening with respect to the iteration?
Lock & unlock once only when the iterator object is created? Lock & unlock
with each iteration? Lock before first iteration & unlock on disposal after
last iteration?