Suspended Thread using 100% CPU

I have a thread that watches a folder. When my app deactivates I suspend the thread and start it again when the app is brought to the front. I’ve found that when the thread is suspended (my app is in the background) CPU use goes to 100%. Bringing the app to the front lowers the CPU use to normal levels. Killing the thread prevents the problem. Is this the expected behavior?

I’m running in Cocoa (Snow Leopard) if that matters.

[quote=26184:@Jonathan Ashwell]I have a thread that watches a folder. When my app deactivates I suspend the thread and start it again when the app is brought to the front. I’ve found that when the thread is suspended (my app is in the background) CPU use goes to 100%. Bringing the app to the front lowers the CPU use to normal levels. Killing the thread prevents the problem. Is this the expected behavior?

I’m running in Cocoa (Snow Leopard) if that matters.[/quote]

Unfortunately it is expected for the time being.

If you just care about Cocoa, look into Apple’s FSEvents framework (reference). It’s pretty simple to use and feel free to ask questions

Thanks, Joe. I’ll play around with .kill and .run instead of suspend/resume.

But the APIs look really interesting…

We have with FSEventsMBS class already an implementation for Xojo.