procedure TClientEventHandlers.OnMonitoredItemChanged(
  ASender: TObject;
  sender: OleVariant;
  const eventArgs: _EasyUAMonitoredItemChangedEventArgs);
begin
  // Display the data
  // Remark: Production code would check eventArgs.Exception before accessing

WriteLn(eventArgs.Arguments.NodeDescriptor.ToString, ': ',
    eventArgs.AttributeData.ToString);
Writeln(eventArgs.Arguments.DisplayString);
end;

class procedure SubscribeMonitoredItem.Main;
var
  Client: TEasyUAClient;
  ClientEventHandlers: TClientEventHandlers;
begin
  // Instantiate the client object and hook events
  Client := TEasyUAClient.Create(nil);
  ClientEventHandlers := TClientEventHandlers.Create;
  Client.OnMonitoredItemChanged := ClientEventHandlers.OnMonitoredItemChanged;

  WriteLn('Subscribing...');
  Client.SubscribeMonitoredItem(
    'http://opcua.demo-this.com:51211/UA/SampleServer',
    'nsu=http://test.org/UA/Data/;i=10853',
    1000);

  WriteLn('Processing monitored item changed events for 1 minute...');
  PumpSleep(60*1000);
end;