Reputation: 2038
I have a function that I'm using while(true) to repeatedly scan memory addresses of an application to detect change. I sleep the thread 1 second between iterations and this helps performance. However, is there a way to create a custom event handler to do away with the loops?
Upvotes: 2
Views: 412
Reputation: 9664
Have you looked into using a Timer with an Interval of 1000 (milliseconds)?
This also gives you a clean way out of your polling by simply destroying the timer, instead of having to check some condition and breaking out of your while loop.
Upvotes: 2