언어

DTSReadOnlyCollectionBase.IsSynchronized 속성

정의

액세스 DTSReadOnlyCollectionBase 가 동기화되는지 여부를 나타내는 값을 가져옵니다(스레드로부터 안전).

public:
 property bool IsSynchronized { bool get(); };
public bool IsSynchronized { get; }
member this.IsSynchronized : bool
Public ReadOnly Property IsSynchronized As Boolean

속성 값

에 대한 접근 DTSReadOnlyCollectionBase 이 동기화되어 있을 때(스레드 안전) true; 그렇지 않으면 false입니다. 기본값은 false입니다.

구현

예제

이 ArrayList 클래스는 속성을 상속하고 구현 IsSynchronized 하는 .NET 프레임워크 클래스입니다. 다음 코드 예제에서는 동기화 ArrayList하는 방법을 보여 하며 동기화되었는지 ArrayList 확인하고 동기화된 ArrayList항목을 사용합니다.

using System;  
using System.Collections;  
public class SamplesArrayList    
{  
   public static void Main()    
   {  
      // Creates and initializes a new ArrayList.  
      ArrayList myAL = new ArrayList();  
      myAL.Add( "The" );  
      myAL.Add( "quick" );  
      myAL.Add( "brown" );  
      myAL.Add( "fox" );  

      // Creates a synchronized wrapper around the ArrayList.  
      ArrayList mySyncdAL = ArrayList.Synchronized( myAL );  

      // Displays the sychronization status of both ArrayLists.  
      Console.WriteLine( "myAL is {0}.", myAL.IsSynchronized ? "synchronized" : "not synchronized" );  
      Console.WriteLine( "mySyncdAL is {0}.", mySyncdAL.IsSynchronized ? "synchronized" : "not synchronized" );  
   }  
}  
Imports System  
Imports System.Collections  
Public Class SamplesArrayList  
   Public Shared  Sub Main()  
      ' Creates and initializes a new ArrayList.  
      Dim myAL As ArrayList =  New ArrayList()   
      myAL.Add("The")  
      myAL.Add("quick")  
      myAL.Add("brown")  
      myAL.Add("fox")  

      ' Creates a synchronized wrapper around the ArrayList.  
      Dim mySyncdAL As ArrayList =  ArrayList.Synchronized(myAL)   

      ' Displays the sychronization status of both ArrayLists.  
      Console.WriteLine("myAL is {0}.", myAL.IsSynchronized ? "synchronized" : "not synchronized")  
      Console.WriteLine("mySyncdAL is {0}.", mySyncdAL.IsSynchronized ? "synchronized" : "not synchronized")  
   End Sub  
End Class  

샘플 출력:

myAL은 동기화되어 있지 않습니다.

mySyncdAL은 동기화되어 있습니다.

설명

ICollection.IsSynchronized를 구현합니다. 컬렉션이 스레드로부터 안전한 경우 속성이 IsSynchronized 반환 true되고 프로그래머가 컬렉션 스레드를 안전하게 유지하기 위해 아무 작업도 수행할 필요가 없습니다.

속성이 를 반환 false하면 SyncRoot 속성은 C# lock 키워드와 함께 사용할 수 있는 객체를 반환합니다. 자세한 내용은 ICollection.IsSynchronized를 참조하세요.

적용 대상