A framework for building background tasks