Hans, I think you should have mentioned that you are using this code in the context of an OpenDCL project, as that is most likely the reason for the problems you experience.
As I have already explained (
here) you cannot use command calls in event handlers for modal OpenDCL forms.
For modeless OpenDCL forms the Event Invoke property of controls must be set to Asynchronous if you want to use commands in their event handlers.