Invoked when the MobiLink Listener for server-initiated synchronizations calls the application to perform synchronization.
Visual Basic Public Sub ServerSyncInvoked( _ ByVal messageName As String _ )
C# public void ServerSyncInvoked( string messageName );
messageName The name of the message sent to the application.
This method is invoked by a separate thread. To avoid multi-threading issues, it should post an event to the UI. If you are using multi-threading, it is recommended that you use a separate connection and use the lock keyword to access any objects shared with the rest of the application.
The following code fragments demonstrate how to receive a server synchronization request and perform a synchronization in the UI thread.
' Visual Basic Imports iAnywhere.Data.UltraLite Public Class MainWindow Inherits System.Windows.Forms.Form Implements ULServerSyncListener Private conn As ULConnection Public Sub New(ByVal args() As String) MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call ULConnection.DatabaseManager.SetServerSyncListener( _ "myCompany.mymsg", "myCompany.myapp", Me _ ) 'Create Connection ... End Sub Protected Overrides Sub OnClosing( _ ByVal e As System.ComponentModel.CancelEventArgs _ ) ULConnection.DatabaseManager.SetServerSyncListener( _ Nothing, Nothing, Nothing _ ) MyBase.OnClosing(e) End Sub Public Sub ServerSyncInvoked(ByVal messageName As String) _ Implements ULServerSyncListener.ServerSyncInvoked Me.Invoke(New EventHandler(AddressOf Me.ServerSyncAction)) End Sub Public Sub ServerSyncAction( _ ByVal sender As Object, ByVal e As EventArgs _ ) ' Do Server sync conn.Synchronize() End Sub End Class |
// C# using iAnywhere.Data.UltraLite; public class Form1 : System.Windows.Forms.Form, ULServerSyncListener { private System.Windows.Forms.MainMenu mainMenu1; private ULConnection conn; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after // InitializeComponent call // ULConnection.DatabaseManager.SetServerSyncListener( "myCompnay.mymsg", "myCompany.myapp", this ); // Create connection ... } protected override void Dispose( bool disposing ) { base.Dispose( disposing ); } protected override void OnClosing( System.ComponentModel.CancelEventArgs e ) { ULConnection.DatabaseManager.SetServerSyncListener( null, null, null ); base.OnClosing(e); } public void ServerSyncInvoked( string messageName ) { this.Invoke( new EventHandler( ServerSyncHandler ) ); } internal void ServerSyncHandler(object sender, EventArgs e) { conn.Synchronize(); } } |
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |