SortedList.IsSynchronized プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SortedList.IsSynchronized プロパティの意味・解説 

SortedList.IsSynchronized プロパティ

SortedList へのアクセス同期されている (スレッド セーフである) かどうかを示す値を取得します

名前空間: System.Collections
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overridable ReadOnly
 Property IsSynchronized As Boolean
Dim instance As SortedList
Dim value As Boolean

value = instance.IsSynchronized
public virtual bool IsSynchronized { get;
 }
public:
virtual property bool IsSynchronized {
    bool get ();
}
/** @property */
public boolean get_IsSynchronized ()
public function get IsSynchronized
 () : boolean

プロパティ
SortedList へのアクセス同期されている (スレッド セーフである) 場合trueそれ以外場合false既定値false です。

解説解説
使用例使用例

列挙処理中に SyncRoot を使用してコレクションロックする方法次のコード例示します

SortedList myCollection = new SortedList();
  lock(myCollection.SyncRoot) {
  foreach (Object item in myCollection) {
  // Insert your code here.
  }
 }
Dim myCollection As New
 SortedList()
 Dim item As Object
 SyncLock myCollection.SyncRoot
  For Each item In myCollection
  ' Insert your code here.
  Next item
 End SyncLock

このプロパティ値を取得することは、O(1) 操作なります

SortedList同期する方法と、SortedList同期されているかどうか確認し同期済みSortedList使用する方法の例を次に示します

Imports System
Imports System.Collections
Imports Microsoft.VisualBasic

Public Class SamplesSortedList
    
    
    Public Shared Sub Main()
        
        ' Creates and initializes a new SortedList.
        Dim mySL As New
 SortedList()
        mySL.Add(2, "two")
        mySL.Add(3, "three")
        mySL.Add(1, "one")
        mySL.Add(0, "zero")
        mySL.Add(4, "four")
        
        ' Creates a synchronized wrapper around the SortedList.
        Dim mySyncdSL As SortedList = SortedList.Synchronized(mySL)
        
        ' Displays the sychronization status of both SortedLists.
        Dim msg As String
        If mySL.IsSynchronized Then
            msg = "synchronized"
        Else
            msg = "not synchronized"
        End If
        Console.WriteLine("mySL is {0}.", msg)
        If mySyncdSL.IsSynchronized Then
            msg = "synchronized"
        Else
            msg = "not synchronized"
        End If
        Console.WriteLine("mySyncdSL is {0}.", msg)
        
    End Sub
End Class

' This code produces the following output.
'
' mySL is not synchronized.
' mySyncdSL is synchronized.
using System;
using System.Collections;
public class SamplesSortedList  {

   public static void Main()
  {

      // Creates and initializes a new SortedList.
      SortedList mySL = new SortedList();
      mySL.Add( 2, "two" );
      mySL.Add( 3, "three" );
      mySL.Add( 1, "one" );
      mySL.Add( 0, "zero" );
      mySL.Add( 4, "four" );

      // Creates a synchronized wrapper around the SortedList.
      SortedList mySyncdSL = SortedList.Synchronized( mySL );

      // Displays the sychronization status of both SortedLists.
      Console.WriteLine( "mySL is {0}.", mySL.IsSynchronized ? "synchronized"
 : "not synchronized" );
      Console.WriteLine( "mySyncdSL is {0}.", mySyncdSL.IsSynchronized
 ? "synchronized" : "not synchronized" );
   }
}
/* 
This code produces the following output.

mySL is not synchronized.
mySyncdSL is synchronized.
*/ 
#using <system.dll>

using namespace System;
using namespace System::Collections;
int main()
{
   
   // Creates and initializes a new SortedList.
   SortedList^ mySL = gcnew SortedList;
   mySL->Add( 2, "two" );
   mySL->Add( 3, "three" );
   mySL->Add( 1, "one" );
   mySL->Add( (int^)0, "zero" );
   mySL->Add( 4, "four" );
   
   // Creates a synchronized wrapper around the SortedList.
   SortedList^ mySyncdSL = SortedList::Synchronized( mySL );
   
   // Displays the sychronization status of both SortedLists.
   Console::WriteLine( "mySL is {0}.", mySL->IsSynchronized ? (String^)"synchronized"
 : "not synchronized" );
   Console::WriteLine( "mySyncdSL is {0}.", mySyncdSL->IsSynchronized
 ? (String^)"synchronized" : "not synchronized" );
}

/*
This code produces the following output.

mySL is not synchronized.
mySyncdSL is synchronized.
*/
import System.*;
import System.Collections.*;

public class SamplesSortedList
{
    public static void main(String[]
 args)
    {
        // Creates and initializes a new SortedList.
        SortedList mySL = new SortedList();

        mySL.Add((Int32)2, "two");
        mySL.Add((Int32)3, "three");
        mySL.Add((Int32)1, "one");
        mySL.Add((Int32)0, "zero");
        mySL.Add((Int32)4, "four");

        // Creates a synchronized wrapper around the SortedList.
        SortedList mySyncdSL = SortedList.Synchronized(mySL);

        // Displays the sychronization status of both SortedLists.
        Console.WriteLine("mySL is {0}.", (mySL.get_IsSynchronized()) ?
 
            "synchronized" : "not synchronized");
        Console.WriteLine("mySyncdSL is {0}.", 
            (mySyncdSL.get_IsSynchronized()) ? 
            "synchronized" : "not synchronized");
    } //main
} //SamplesSortedList

/* 
 This code produces the following output.
 
 mySL is not synchronized.
 mySyncdSL is synchronized.
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からSortedList.IsSynchronized プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSortedList.IsSynchronized プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSortedList.IsSynchronized プロパティを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SortedList.IsSynchronized プロパティ」の関連用語

SortedList.IsSynchronized プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SortedList.IsSynchronized プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS