extension of NSRunLoop for waiting for flag