You say you have a signed purchase agreement for a house that's being foreclosed upon. Is it a short sale? If it is then the lender must OK the purchase agreement as well. You didn't say how much into the future these events are occurring. It's often difficult to speed a lender along in agreeing to a short sale. But, if that's the case, then your Realtor should be in daily contact with the lender. You can also ask the lender to delay the sale, but I haven't heard of that technique working very often.
If it's not a short sale, one option is to get the lender to delay the foreclosure. Possible, but not likely. Moving up your closing date would be best, but, as you noted, may not be possible because you still need to sell your home. I've heard very good things about these "Sell Your Home in 5-Day" strategies. Really, though, it takes 2-3 weeks, at a minimum--relies on blitz marketing and a round-robin auction. You might look into that as a way of selling your home quickly.