Replacing Thread sleep with CFRunLoopRunInMode