Using timer might solve your issue, if what you need to do is to e.g. periodically check something.
Alternative is to "invert" message loop, or basically make your code the message loop: Instead of .Run (or .Execute) start your code and into some place that is passed through frequently enought (like each 1ms), put