Error at getting item from a UserDefinedEvent

Hello,

We have an application where we create a UserDefinedEvent using:

ManagementServer.UserDefinedEventFolder.AddUserDefinedEvent().

Subsequently, to trigger this event, we need the FQID. For this, we search for the UserDefinedEvent using:

ManagementServer.UserDefinedEventFolder.UserDefinedEvents.SingleOrDefault().

Up to this point, everything works fine. However, the issue arises when obtaining the Item to retrieve the FQID. We use the function:

Configuration.Instance.GetItem(UserDefinedEvent.ServerId, UserDefinedEvent.Guid, Kind.TriggerEvent),

which returns null until the application is restarted.

Is there a way to resolve this issue without restarting the application?

Thank you!

What you describe is not an error as such, but the intended design. A MIP SDK based application will read Configuration at startup. It does not read it continuedly. (You can also observe that the Smart Client does not include a camera that was added after it was started, restarting the Smart Client is a way to ensure new cameras are picked up.)

You can restart the application but there is a way to reload the Configuration.

Let me describe the way it should be done:

  1. Subscribe to LocalConfigurationChangedIndication
  2. Ask for a ReloadConfiguration
  3. When the LocalConfigurationChangedIndication is triggered you know the new Configuration is ready for use.

I will give you some minimal code snippets to illustrate:

private void ListenOnLocalConfigChangedIndication()
{
	EnvironmentManager.Instance.RegisterReceiver(GetLocalSysChange, new MessageIdFilter(MessageId.System.LocalConfigurationChangedIndication));
	EnvironmentManager.Instance.Log(false, "Listen", "reg EnvironmentManager.Instance.RegisterReceiver LocalConfigurationChangedIndication");
}
 
private object GetLocalSysChange(VideoOS.Platform.Messaging.Message message, FQID destination, FQID sender)
{
	EnvironmentManager.Instance.Log(false, "GetLocalSysChange", "yes");
}
 
private void DoReload()
{
	VideoOS.Platform.SDK.Environment.ReloadConfiguration(Configuration.Instance.ServerFQID);
	EnvironmentManager.Instance.Log(false, "DoReload", "yes");
}

While testing I also had a snippet of code to change a camera name, and a snippet of code to log the cameras name as it appeared in Configuration. You should instead be able to see that before the reload you cannot find the event you create, and after the reload you can find it.

PS. In principle you might be able to use the reloaded configuration almost instantly, however the safe way is to await a confirming LocalConfigurationChangedIndication.