Fixed issue with Threading

Changed software to use a while loop rather than a thread.sleep to
prevent locking up of UI elements (since tasks can be scheduled to run
on the same thread potentially as the UI).