IsSynchronized false inside lock(ICollection.SyncRoot) ?

  • Thread starter Thread starter anon
  • Start date Start date
A

anon

Isnt IsSynchronized supose to return True?
Sadly the reference topic on IsSynchronized includes a small sample code
that only mentions lock(SyncRoot) with no example of what IsSynchronized is
supose to do.
Real sad :(

Alex

using System;
using System.Collections;
....
ArrayList MyICollection = new ArrayList(10);
lock (MyICollection.SyncRoot)
{
Console.WriteLine("Sync: {0}", MyICollection.IsSynchronized);
}
....
 
anon said:
Isnt IsSynchronized supose to return True?

Not unless the ArrayList itself is synchronized. The code you gave
locks an unsynchronized ArrayList, which is a different matter.
Sadly the reference topic on IsSynchronized includes a small sample code
that only mentions lock(SyncRoot) with no example of what IsSynchronized is
supose to do.

Um, we must be looking at different pages then. The MSDN page I'm
looking at gives pretty reasonable information, and an example which
creates a synchronized ArrayList from an unsynchronized one.
 
Back
Top