fix for race condition when callback is invoked from thread pool