Split program into two threads.  First is for GUI control, second for an IO monitor that continuously runs and acts upon inputs received from the GUI.