I've implemented an OpenUI control for the Work Manager 6.1 WPF client which reads the current GPS location of the device and periodically sends it a scheduling system. The control is part of MainMenuScreen and works fine as long as the MainMenuScreen is open. It uses a Timer object to periodically run the following code to trigger an Agentry section which runs an Agentry transaction to send the GPS position:
AgentryClientSDK.IAgentryControlViewModelStringDisplay vm = DataContext as AgentryClientSDK.IAgentryControlViewModelStringDisplay;
if (vm != null)
If the MainMenuScreen set is closed by the user so that only the Agentry client screen with the module list, the "Go On/Offline" button etc is visible and the Timer event fires to execute the coding above, I get this error when executing vm.DoesAgentryActionExist():
As soon as the user clicks "OK", Agentry client closes. There is no exception being raised.
According to this website, the error happens if a virtual function is called in a constructor or destructor. As at that line of code my coding is not doing that, I assume that it's caused by Agentry client.
Calling the whole code could be avoided if there is a way to check whether the Screenset/Screen on which the OpenUI control is located is still open or not but I haven't found a way yet.
Also it feels for me that the OpenUI control life-cycle is a little buggy. I would expect that if you close MainMenuScreen that it gets disposed.
Has anyone faced a similar situation yet or has suggestions how to check whether MainMenuScreen is open or not?