Open topic with navigation

TIBCO GridServer® 7.1.0

# Collecting Results During Asynchronous Execution

Since Visual Basic is not multithreaded, there are no callbacks for results collection. The `collectNext` function is used for collecting results during asynchronous calls. The function returns one of the available results from the Service; if none are available, it waits for the number of milliseconds supplied as an input argument before returning. The timeout prevents a client application from waiting indefinitely on a Service.

`collectNext` returns the result as a `ServiceData` type, which includes the following properties:

| • | `Id` — The Service invocation ID, which can be used to match the result with the corresponding submission.

| • | `IsError` — A Boolean that signifies whether the execution resulted in an error; if so, the data property contains the error message.

| • | `Data` — The result (Service function returns value or error).

For the same reason as `execution` and `submit` functions, all output arguments are pure strings.

To make collecting multiple results easier, the `InvocationCount` parameter of a Service is equal to the number of outstanding invocations.

The following code demonstrates how one can implement results collection. It repeatedly checks a Service for available results. If there are results, one result is collected; the code checks to see if the result is an error, and prints out the result data accordingly. If there are no results, it waits for 1 second, and then loops. The loop ends when all the results have been collected.

    While service.InvocationCount > 0
    	Dim sd As ServiceData
    	Set sd = service.collectNext(1000)
    	If Not sd Is Nothing Then
    		If sd.IsError Then
    			Debug.Print "collected " & sd.Id & " error: " & sd.Data
    		Else
    			Debug.Print "collected " & sd.Id & ": " & sd.Data
    		End If
    	End If
    Wend
    Debug.Print "done collecting"

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO GridServer®

Copyright © 2001-2022. TIBCO Software Inc. All Rights Reserved.