SharedData Last Method C# API
Reads the last value from the specified value list in the Shared Data Server.

Namespace: Facilita.Fc.Runtime
Assembly: fc_clr (in fc_clr.dll) Version: 9.5.8.37
Syntax

public string Last(
	string key,
	int timeout
)

Parameters

key
Type: System String
The key against which the data is stored.
timeout
Type: System Int32
The maximum time in milliseconds to wait for a value to become available.

Return Value

The last value in the list.
Remarks

Set the timeout parameter to 0 (zero) to prevent blocking. Use -1 to wait forever. If no list of values exists for key, then the Virtual User thread will be suspended and the call will only return (dependent upon timeout) when a value is read from the Shared Data server. If the connection to the Shared Data Server is lost an exception is raised.

Note Note
The keys are case-sensitive.

Note Note
The value is not removed from the list.

Examples

The following example demonstrates reading the last value from a list.
using Facilita.Fc.Runtime;
SharedData sharedData = new SharedData(GetString("sharedDataHost", "localhost"), GetInt("sharedDataPort", 5099));
string userID = sharedData.Last("UID", 20000);   // wait 20 seconds; an exception is raised on timeout 
// Alternate method that catches the exception if no value for key or timeout 
try
{
    userID = sharedData.Last("UID", 0);   // do not wait for a value
}
catch (Exception e)
{
    Error(String.Format("NoValue: {0}", e)); // error is "key=NoValue"
    NextIteration();
}
See Also