Using C#, how do I enable the user press the Escape button to stop a process from happening? Rhino student needs help!

I have an infinite while loop in my code drawing a random increasing curve. At any given time I want to press escape to stop the process, but when I use the GetString() function it stops the background process, at least until I press Enter again. I tried using Windows.Form, but that didn’t work. How can I accomplish my goal?

There is an event in RhinoCommon called EscapePressed

You can find more info here http://4.rhino3d.com/5/rhinocommon/html/E_Rhino_RhinoApp_EscapeKeyPressed.htm

Generally, you can find info on RhinoCommon here http://4.rhino3d.com/5/rhinocommon/

Are there any examples of code using this event? I’m not too familiar with
the event types in C# yet.

Also, does it work similar to RhinoApp.KeyboardEventHandler?

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsEscapeKey.cs

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsEscapeKey2.cs

1 Like

Hello @dale , this link dont work, can you post another?

thanks