I used the SetWindowHookEx() API in the SetWindowHookEx() and to receive OS notifications. I ran Application Message Pump using Application.Run() .
Now I want to stop the message pump and exit the workflow, but I have no good way to stop the flow.
Alternatively, I use the Thread.Abort() method to end the thread, but it is not recommended to end the thread gracefully.
Can anyone suggest how to gracefully close the message pump from the user interface stream or main form so that the workflow automatically returns and exits?
source share