Skip to main content
RSS feed Subscribe to feed


Asynchronous Evaluation Workflow

Spotfire Statistics Services handles evaluations either synchronously or asynchronously.


You typically specify a synchronous evaluation if a job is expected to be handled quickly and if it does not pose a problem if the execution thread is blocked until the job is complete. If the request may take a while, or if the results are not needed immediately, the request can be sent aysnchronously by setting the Eval() argument isAsync to true. If an asynchronous request shall be run at a specified time, call Eval(), passing a DateTime structure containing the date and time.

Asynchronous Evaluation Options

When sending an asynchronous evaluation to Spotfire Statistics Services, either track its status by calling GetJobDetails(), or add an event handler to be called when the job is complete.

  • Use the first version if the user is not interested in being notified when the job is complete. To find out the status of the request, call GetJobDetails, passing the SplusDataResult property JobId. (The status that can be waiting, running, interrupted, failed, or done.)
    execJob = api.Eval(expr, true);
    //go off and do something
  • Use the second version if to perform an action upon job completion (like alerting the user). Note that it is possible to never receive notifications even if the job is complete as the protocol used to send the notifications is UDP, which does not maintain a persistent connection and can theretically result in packet loss, though the probabililty of this ever occurring on a local area network is very low. In this case, the user can find the jobs by using GetJobs() to look for the jobs, or by calling the client base function GetJobDetails() if the job ID was captured.)
    The following registers a notification listener to be called when the job state changes on the server and obtain the current job status:
    string jobIdNotified = null;
    Client.SetNotificationListener(delegate(NotificationMessage message)
        jobIdNotified = message.JobId;
        if ((message.Type == eNotificationType.eJobStatusChanged) && (message.JobStatus == SplusStatus.Done))
            Console.WriteLine("job is completed for jobId " + jobIdNotified);

Asynchronous Evalutation of an Expression

The following diagram illustrates how an asynchronous expression is sent to the server, waits for an available engine, and then runs. Note that when an asynchronous evaluation is sent to the server, it returns the SplusDataResult object containing the job ID immediately, so you can query the server for the job's status or interrupt the job run, if necessary.

Diagram of asynchronous job processing