SyncAgent クラス

SyncAgent オブジェクトは同期を調整します。

名前空間:  Microsoft.Synchronization
アセンブリ:  Microsoft.Synchronization.Data (Microsoft.Synchronization.Data.dll 内)

構文

'宣言
Public Class SyncAgent _
    Implements IDisposable
'使用
Dim instance As SyncAgent
public class SyncAgent : IDisposable
public ref class SyncAgent : IDisposable
type SyncAgent =  
    class
        interface IDisposable
    end
public class SyncAgent implements IDisposable

説明

SyncAgent は同期する各テーブルをループ処理し、クライアント同期プロバイダーを呼び出してクライアント データベースで変更を取得および適用します。その後、サーバー同期プロバイダーを呼び出してサーバー データベースで変更を取得および適用します。

次のコード例では、SyncAgent から派生するクラスを作成します。クラスでは、クライアント同期プロバイダーおよびサーバー同期プロバイダーをインスタンス化し、同期グループを作成して、Customer テーブルを追加します。テーブルを追加する場合は、同期の方向およびテーブル作成オプションも指定されます。完全なコンテキスト例でこのコードを表示するには、「クライアントとサーバー間で双方向でデータの増分変更を交換する方法」を参照してください。

public class SampleSyncAgent : SyncAgent
{
    public SampleSyncAgent()
    {            
        //Instantiate a client synchronization provider and specify it
        //as the local provider for this synchronization agent.
        this.LocalProvider = new SampleClientSyncProvider();

        //Instantiate a server synchronization provider and specify it
        //as the remote provider for this synchronization agent.
        this.RemoteProvider = new SampleServerSyncProvider();

        //Create a Customer SyncGroup. This is not required
        //for the single table we are synchronizing; it is typically
        //used so that changes to multiple related tables are 
        //synchronized at the same time.
        SyncGroup customerSyncGroup = new SyncGroup("Customer");

        //Add the Customer table: specify a synchronization direction of
        //Bidirectional, and that an existing table should be dropped.
        SyncTable customerSyncTable = new SyncTable("Customer");
        customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
        customerSyncTable.SyncDirection = SyncDirection.Bidirectional;
        customerSyncTable.SyncGroup = customerSyncGroup;
        this.Configuration.SyncTables.Add(customerSyncTable);
    }
}
Public Class SampleSyncAgent
    Inherits SyncAgent

    Public Sub New()
        'Instantiate a client synchronization provider and specify it
        'as the local provider for this synchronization agent.
        Me.LocalProvider = New SampleClientSyncProvider()

        'Instantiate a server synchronization provider and specify it
        'as the remote provider for this synchronization agent.
        Me.RemoteProvider = New SampleServerSyncProvider()

        'Create a Customer SyncGroup. This is not required
        'for the single table we are synchronizing; it is typically
        'used so that changes to multiple related tables are 
        'synchronized at the same time.
        Dim customerSyncGroup As New SyncGroup("Customer")

        'Add the Customer table: specify a synchronization direction of
        'Bidirectional, and that an existing table should be dropped.
        Dim customerSyncTable As New SyncTable("Customer")
        customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable
        customerSyncTable.SyncDirection = SyncDirection.Bidirectional
        customerSyncTable.SyncGroup = customerSyncGroup
        Me.Configuration.SyncTables.Add(customerSyncTable)

    End Sub 'New
End Class 'SampleSyncAgent

継承階層

System. . :: . .Object
  Microsoft.Synchronization..::..SyncAgent

スレッド セーフ

この型の public static (Visual Basic では Shared) のメンバーはスレッド セーフです。インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

参照

参照

SyncAgent メンバー

Microsoft.Synchronization 名前空間