Unable to cancel running command and start a new one

I create a toolbar with 2 custom buttons associated with my 2 custom commands.

When I click a button to start a command, I cannot start another command by clicking the button in my toolbar. The same behavior can be observed if I start a Rhino native command first, like _Point.

But I found native Rhino native commands, like _Point, doesn’t have such issue. It can cancel other commands and start itself.

Could anyone help me check if there is anything wrong with my code?

I’v attached my simplified test code and a video to show the issue. My Rhino version is 7.4. Thank you in advance.

RhinoCommonIssueTest.7z (4.1 MB)

See my reply here

That said, have you read through Rhinoceros Help and tried the exclamation mark?

Hello, thank you for your reply. I’ve re-tested the issue using a non-cracked Rhino 6.35 and the issue is still reproducible.

I know run macro like RhinoApp.Runscript("!", false); should be able to cancel a command, but when I click my custom command, “RunCommand” method is not called so I don’t know where to run the macro to cancel the currently running command.

There is not such issue with native Rhino commands, so I guess maybe I miss something in my code or there is some trick to achieve this?

Please check the attachment for details.

UnableToStartCommand.7z (2.0 MB)

You can set to the button also something like ! YourCommandName. That will cancel first any running commands just before running your command.