Your method check()
'pauses' the app because its job is currently executed in the UI thread.
If you don't want that your method freezes the UI, you should schedule the execution of the method in a background thread, different from your UI thread.
You can do that using a BackgroundWorker thread. An example, as suggested by @qujck, is here.