Invoked when the MobiLink provider for ActiveSync calls the application to perform synchronization.
Visual Basic Public Sub ActiveSyncInvoked( _ ByVal launchedByProvider As Boolean _ )
C# public void ActiveSyncInvoked( bool launchedByProvider );
launchedByProvider True if the application was launched by the MobiLink provider to perform ActiveSync synchronization. The application must then shut itself down after it has finished synchronizing. False if the application was already running when called by the MobiLink provider for ActiveSync.
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.
Once synchronization has completed, applications should call ULDatabaseManager.SignalSyncIsComplete() to signal the MobiLink provider for ActiveSync.
The following code fragments demonstrate how to receive an ActiveSync request and perform a synchronization in the UI thread.
' Visual Basic
Imports iAnywhere.Data.UltraLite
Public Class MainWindow
Inherits System.Windows.Forms.Form
Implements ULActiveSyncListener
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.SetActiveSyncListener( _
"myCompany.myapp", Me _
)
'Create Connection
...
End Sub
Protected Overrides Sub OnClosing( _
ByVal e As System.ComponentModel.CancelEventArgs _
)
ULConnection.DatabaseManager.SetActiveSyncListener( _
Nothing, Nothing _
)
MyBase.OnClosing(e)
End Sub
Public Sub ActiveSyncInvoked( _
ByVal launchedByProvider As Boolean _
) Implements ULActiveSyncListener.ActiveSyncInvoked
Me.Invoke(New EventHandler(AddressOf Me.ActiveSyncAction))
End Sub
Public Sub ActiveSyncAction( _
ByVal sender As Object, ByVal e As EventArgs _
)
' Do active sync
conn.Synchronize()
ULConnection.DatabaseManager.SignalSyncIsComplete()
End Sub
End Class
|
// C#
using iAnywhere.Data.UltraLite;
public class Form1 : System.Windows.Forms.Form, ULActiveSyncListener
{
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.SetActiveSyncListener(
"myCompany.myapp", this
);
// Create connection
...
}
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
protected override void OnClosing(
System.ComponentModel.CancelEventArgs e
)
{
ULConnection.DatabaseManager.SetActiveSyncListener(
null, null
);
base.OnClosing(e);
}
public void ActiveSyncInvoked(bool launchedByProvider)
{
this.Invoke( new EventHandler( ActiveSyncHandler ) );
}
internal void ActiveSyncHandler(object sender, EventArgs e)
{
conn.Synchronize();
ULConnection.DatabaseManager.SignalSyncIsComplete();
}
}
|
| Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |