Programmatically waiting on SharePoint Solutions to deploy

I recently had the need to deploy multiple solutions via the object model, but of course had to wait for each solution to successfully deploy before moving to the next, etc.  Another requirement is that I needed a common code base that would work on either SharePoint 2007 or SharePoint 2010.  And of course, needed …