add callback to do background tasks while waiting for input