I want to add some while() loop to a windows form app, the problem is that when I try its freezing the window because of the loop.

There is any way or method to add a loop that won't freeze the window?

Maybe you should add a thread.