ControlCollection.IsSynchronized Property
Gets a value indicating whether the ControlCollection is synchronized.
[Visual Basic] Public Overridable ReadOnly Property IsSynchronized As Boolean _ Implements ICollection.IsSynchronized [C#] public virtual bool IsSynchronized {get;} [C++] public: __property virtual bool get_IsSynchronized(); [JScript] public function get IsSynchronized() : Boolean;
Property Value
This property is always false.
Implements
Example
[Visual Basic] The following example creates a method that enumerates through the ControlCollection of a Button control, myButton. Once the enumerator is created, the IsSynchronized property is checked to see if the operation is thread-safe, and if it is not, the SyncRoot property is used to obtain an object to make the operation thread-safe. Once the enumeration is complete, the value of the IsReadOnly property is written as the Text property of a Label control on the containing page.
[Visual Basic]
' Create a method that enuberates through a
' button's ControlCollection in a thread-safe manner.
Public Sub ListControlCollection(sender As Object, e As EventArgs)
Dim myEnumerator As IEnumerator = myButton.Controls.GetEnumerator()
' Check the IsSynchronized property. If False,
' use the SyncRoot method to get an object that
' allows the enumeration of all controls to be
' thread safe.
If myButton.Controls.IsSynchronized = False Then
SyncLock myButton.Controls.SyncRoot
While (myEnumerator.MoveNext())
Dim myObject As Object = myEnumerator.Current
Dim childControl As LiteralControl = CType(myEnumerator.Current, LiteralControl)
Response.Write("<b><br> This is the text of the child Control </b>: " & _
childControl.Text)
End While
msgReadOnly.Text = myButton.Controls.IsReadOnly.ToString()
End SyncLock
End If
End Sub
[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
ControlCollection Class | ControlCollection Members | System.Web.UI Namespace | Controls