Create a RealTimeSetRecord from a RealTimeRecord using the RealTimeRecord number
- Last UpdatedApr 08, 2026
- 2 minute read
This scenario guides you through the steps required to create a RealTimeSetRecord object from a RealTimeRecord.
To identify the code associated with each step, see the code comments in the Example code section.
Before you begin
- Open the Program.cs file from the created project.
- Open the RealTime database (RTDB).
- Review the list of additional namespaces needed for the desired scenario.
using SetTableLockRequestType = OASySDNA.RealTime.HighPerformanceSetDB.TableLockRequestType; using SetRecordLockRequestType = OASySDNA.RealTime.HighPerformanceSetDB.RecordLockRequestType;
To create a RealTimeSetRecord
- Lock the analog table for reading.
- Find the analog record to get its pointer name.
- Lock the analog table for reading.
- Get the RealTimeSetTable.
- Lock the RealTimeSetTable.
- Create the RealTimeSetRecord object.
- Unlock the set record.
- Unlock the set table.
- Unlock the analog table.
Example code
IRealTimeDatabase database = new RealTimeDatabase();
try
{
// Open the RTDB.
if (!database.IsOpen())
{
database.Open();
}
using (IRealTimeTable table = new RealTimeTable("analog"))
{
ITableLockRequestType tableLockRequest = new TableLockRequestType();
IRecordLockRequestType recordLockRequest = new RecordLockRequestType();
// Lock the analog table for reading.
table.Lock(tableLockRequest.SAFE_READ);
// Find the analog record to get its pointer name.
var nameField = new RealTimeStringField(table, "name");
using (var record = table.FindRecord(nameField, "AutoCommandAnalog01"))
{
// Get the RealTimeSetTable.
using (var setTable = (RealTimeSetTable)table.GetRealTimeSetTable())
{
// Lock the RealTimeSetTable.
setTable.Lock(SetTableLockRequestType.SAFE_READ);
// Create the RealTimeSetRecord object.
using (var setRecord = new RealTimeSetRecord(setTable, record.RecordNumber))
{
setRecord.Lock(SetRecordLockRequestType.SAFE_READ);
// User code that uses set record.
var desc = setRecord.ReadField<String>("description");
Console.WriteLine(quot;Description: {desc}");
} // Leaving scope releases the set record lock.
} // Leaving scope releases the set table lock.
}
} // Leaving scope releases the analog table lock.
}
catch (Exception ex)
{
Console.WriteLine(quot;Error getting the RealTimeSetRecord: {ex.Message}");
}