immediately. But you can try to find a work (transfer to H1) if possible.Or marry an H1 to become H4 if needed before the possible I485 denial. There might be some other methods, but none of them seems easy.
Usually "very few" people have problems with I485 if I140 passed. So I suggest what you could do is to evalute your I485 case. If you do have things that will most likely kill your I485, then you might don't want to apply I140 at all. If not, it might worth to take the risk.
For F-1 students, I strongly suggest them to apply I140/I485 close to the end of their study. In this way, they will not only have as more supporting as possible, but also are more likely to be able to find a job soon, thus with H-1B to prepare for the worst scienario. If you have H-1B status, then there should be nothing they need to worry about.
Somebody correct me if I am wrong.