Stopping the SDK

The RUISDK.StopSDK function stops the SDK that was started with RUISDK.StartSDK. If explicit sessions are allowed (multiSessionsEnabled = true in RUISDK.CreateConfig), then any sessions that have been started with RUISDK.StartSession that have not been stopped with RUISDK.StopSession are automatically stopped. A manual synchronization with the RUI Server, RUISDK.Sync, will be performed at stop depending on the value of doSync (as described in Parameters)

RUISDK.StopSDK must be called after RUISDK.StartSDK and must be called only once. After RUISDK.StopSDK is called, the various event tracking APIs are no longer available. The only API available is RUISDK.GetState. The SDK cannot be re-started with a subsequent call to RUISDK.StartSDK.

RUISDK.StopSDK is a synchronous function, including the manual synchronization with the Server (if requested), returning when all functionality is completed.

RUISDK.StopSDK

RUIResult RUISDK.StopSDK (Int32 doSync)¶

Parameters

The RUISDK.StopSDK function has the following parameters.

RUISDK.StopSDK Parameters

Parameter

Description

doSync (Int32)

Indicates whether to do a manual synchronization as part of the stop, and if so, the wait limit.

A manual synchronization with the Server, RUISDK.Sync, will be performed at stop depending on the value of doSync:

1—Do not perform a manual synchronization with the Server as part of the stop.
0—Perform a manual synchronization with the Server as part of the stop; wait indefinitely for completion.
>0—Perform a manual synchronization with the Server as part of the stop; wait only doSync seconds for completion.

Returns

The RUISDK.StopSDK function returns a RUIResult enum value with the following possible values.

RUISDK.StopSDK Returns

Return

Description

ok

Function successful.

sdkInternalErrorFatal

Irrecoverable internal fatal error. No further API calls should be made.

sdkAborted

A required New Registration has failed, and hence the SDK is aborted. RUISDK.StopSDK and RUISDK destructor are possible.

sdkPermanentlyDisabled

The Server has instructed a permanent disable.

configNotCreated

Configuration has not been successfully created.

sdkAlreadyStarted

SDK has already been successfully started.

sdkAlreadyStopped

SDK has already been successfully stopped.

invalidDoSyncValue

The doSync manual sync flag/limit violates its allowable range.

Code Example

This example shows RUISDK.StopSDK being called in the closing event of a form.

// Create instance

bool registerDefaultReachOut = true;

String ruiSDKDLLPath = "<path to Revulytics Usage Intelligence SDK .NET library>";

mySDK = new RUISDK(registerDefaultReachOut, ruiSDKDLLPath);

// Other initialization.....

 

 

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

{

    mySDK.StopSDK(5);

}

Recommendation

If you are using a Windows forms application, the best location to place the RUISDK.StopSDK call would be inside of the entry point method of your application, on the line immediately following the Application.Run call that creates your main form, as seen below. This will allow the Usage Intelligence SDK to execute its final server synchronization procedure AFTER your form has been closed.

Although RUISDK.StopSDK usually takes just a few milliseconds to execute, in case of a slow network connection, the user could experience a small lag from when they hit your application close button until the time the form actually closes. By placing RUISDK.StopSDK in the location below, this delay is completely invisible to the user since the form would have been already closed.

// Create instance

bool registerDefaultReachOut = true;

String ruiSDKDLLPath = "<path to Revulytics Usage Intelligence SDK .NET library>";

mySDK = new RUISDK(registerDefaultReachOut, ruiSDKDLLPath);

// Other initialization.....

 

 

[STAThread]

static void Main()

{

    Application.EnableVisualStyles();

    Application.SetCompatibleTextRenderingDefault(false);

    Application.Run(new Form1());

    mySDK.Stop(5);

}