Two changes I would make:
- Add a timer that continually calls the logic (show/hide the Button/RichTextBox)
- Make the Button and RichTextBox always there, but initially invisible.
To do this, I would (on load) create the Button and RichTextBox with .Visible = false
. Then create a timer that runs every 500 milliseconds (+/-). That timer would call a function that contains the logic you have above. However, instead of creating the controls (with that logic) just reference them and set their visibility.
In essence, create the controls once, run the logic multiple times.