I have a code that has a lot of:
Code:
while(flag)
   Application.DoEvents()
which is very inefficient. It makes my CPU go almost on 100% until the while loop ends.
Is there a way to make this a bit more efficient without really changing the code.

Is this possible? Should I use multiple threads?

I would like a general advice how to achieve the best performance when you have a situation when you have to wait for the user to press lets say a Cancel or Done button in order to continue.

Thanx