Oracle Database Mobile Server .Net Sync API  11.3.0.0.0
Mobile Sync Client .NET API specification
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties
Public Member Functions | Properties | List of all members
Oracle.OpenSync.SyncAgent.BGSession Class Reference
Inheritance diagram for Oracle.OpenSync.SyncAgent.BGSession:

Public Member Functions

 BGSession ()
 
void Dispose ()
 
void Close ()
 
void Start ()
 
void StartInternal ()
 
void Stop ()
 
void Kill ()
 
void Pause ()
 
void Resume ()
 
bool WaitForStatus (BGStatusCode statusCode, long timeOut)
 
void WaitForStatus (BGStatusCode statusCode)
 
BGAgentStatus GetAgentStatus ()
 
BGSyncStatus GetSyncStatus ()
 
void ShowUI ()
 

Properties

BGStatusCode StatusCode [get]
 
BGMessageHandler MessageReceived
 
bool Enabled [get, set]
 

Detailed Description

This class represents background sync control APIs. It allows application to control sync agent (such as start, stop, pause and resume) as well as to get various background sync status information and also to specify custom handlers for events that occur in background sync. Note that in multithreaded environment a single BGSession is not supposed to be used from multiple threads. Each thread should open its own session.

Example:

     BGSession sess = new BGSession();
     using(BGsession sess = new BGSession())
     {
         sess.Start();
         sess.WaitForStatus(BGAgentStatus.RUNNING);
         BGAgentStatus s = sess.getAgentStatus();
         Console.WriteLine("User name: " + s.clientId);
         sess.MessageReceived += new BGMessageHandler(myHandler);
         ...
     }

Constructor & Destructor Documentation

Oracle.OpenSync.SyncAgent.BGSession.BGSession ( )

Create new session to interact with sync agent. Does not automatically start sync agent.

Exceptions
BGException- if the session could not be established
See Also
BGException

Member Function Documentation

void Oracle.OpenSync.SyncAgent.BGSession.Close ( )

Close the session and release all its resources.

See Also
Dispose
void Oracle.OpenSync.SyncAgent.BGSession.Dispose ( )

Close the session and release all its resources.

BGAgentStatus Oracle.OpenSync.SyncAgent.BGSession.GetAgentStatus ( )

Get current sync agent status information.

Returns
sync agent status object
See Also
BGAgentStatus
Exceptions
BGException- if the status could not be obtained
BGSyncStatus Oracle.OpenSync.SyncAgent.BGSession.GetSyncStatus ( )

Get current status of sync within sync agent

Returns
sync status object
See Also
BGSyncStatus
Exceptions
BGException- if the sync status could not be obtained
void Oracle.OpenSync.SyncAgent.BGSession.Kill ( )

Forcefully terminate sync agent process instead of trying to stop it gracefully. Use this option as a last resort, if the Stop method is not working because some tasks are hanging in sync agent. Also not recommended if sync agent was started with StartInternal().

See Also
Stop
StartInternal
void Oracle.OpenSync.SyncAgent.BGSession.Pause ( )

Pause sync agent. If the agent is already paused or being paused this call has no effect. This call is asynchronous, it does not wait for sync agent to be paused before returning. Use waitForStatus(int, long) to wait for sync agent.

Exceptions
BGException- if sync agent is not in the state RUNNING, PAUSED, or PAUSE_PENDING or a system error has occured.
See Also
BGStatusCode
BGException
void Oracle.OpenSync.SyncAgent.BGSession.Resume ( )

Resume sync agent. If the agent is already running, starting, or resuming this call has no effect. This call is asynchronous, it does not wait for sync agent to be resumed before returning. Use waitForStatus(int, long) to wait for sync agent.

Exceptions
BGException- if sync agent is not in the state PAUSED, RESUME_PENDING, START_PENDING or RUNNING or a system error has occured.
See Also
BGStatusCode
BGException
void Oracle.OpenSync.SyncAgent.BGSession.ShowUI ( )

Bring up sync agent UI. Currently this function is not supported for native clients and does nothing.

void Oracle.OpenSync.SyncAgent.BGSession.Start ( )

Start sync agent. If the agent is aready running, starting, or resuming this call has no effect. If the agent is paused, this call with resume the agent. This call is asynchronous, it does not wait for sync agent to be started before returning. Use waitForStatus() to wait for sync agent.

Exceptions
BGException- if sync agent is not in the state STOPPED, START_PENDING, RUNNING, PAUSED or RESUME_PENDING (that is the agent is in the state PAUSE_PENDING or STOP_PENDING), if sync agent is disabled or a system error has occured.
See Also
BGStatusCode
Enabled
BGException
void Oracle.OpenSync.SyncAgent.BGSession.StartInternal ( )

Same as Start, but starts sync agent within application process.

Exceptions
BGException
See Also
Start
void Oracle.OpenSync.SyncAgent.BGSession.Stop ( )

Stop sync agent. If the agent is already stopped or stopping this call has no effect. This call is asynchronous, it does not wait for sync agent to be stopped before returning. Use waitForStatus(int, long) to wait for sync agent.

Exceptions
BGException- if sync agent is not in the state RUNNING, PAUSED, STOPPED or STOP_PENDING or a system error has occured.
See Also
BGStatusCode
BGException
bool Oracle.OpenSync.SyncAgent.BGSession.WaitForStatus ( BGStatusCode  statusCode,
long  timeOut 
)

Wait for sync agent to reach specified status.

Parameters
statusCode- the status to wait for. Only RUNNING, PAUSED or STOPPED are accepted.
timeOut- maximum time to wait for in milliseconds
Returns
true if the agent has reached specified status, false if the timeout has occured.
Exceptions
BGException- if the statusCode parameter is not one of the values above or a system error has occurred.
See Also
BGStatusCode
BGException
void Oracle.OpenSync.SyncAgent.BGSession.WaitForStatus ( BGStatusCode  statusCode)

Wait for sync agent to reached specified status. Same as waitForStatus(int, long) but with unlimited timeout.

Parameters
statusCode- status to wait for
Exceptions
BGException
See Also
WaitForStatus(int, long)

Property Documentation

bool Oracle.OpenSync.SyncAgent.BGSession.Enabled
getset

Gets or sets "Enabled" property of sync agent. The parameter "BGSYNC.DISABLE" in ose.ini will be set to TRUE or FALSE when this property is set to false or true correspondingly. When sync agent is disabled it is not allowed to start. This is useful when only foreground sync is desired.

BGMessageHandler Oracle.OpenSync.SyncAgent.BGSession.MessageReceived
addremove

Adds or removes message handlers used to handle background sync events

Exceptions
BGExceptionif a handler could not be added or removed
See Also
BGMessageHandler
BGStatusCode Oracle.OpenSync.SyncAgent.BGSession.StatusCode
get

Get current sync agent status code.

See Also
GetAgentStatus
BGException