My ex and I decided to split after 23 years of marriage (29 together) when my sons were in their GCSE and A Level years. (He had already had his second chance 8 years previously when he had a short affair - and actually would have left then, but she changed her mind.)
I was persuaded to carry on as normal until after their exams. We did this - and I dare say it was beneficial to them - but he didn't really carry on as normal and just took advantage of this time to line up my replacement whom he married within 6 weeks of our decree absolute coming through. I found it a very difficult year and I don't think my self esteem has ever really recovered.
When he had the initial affair, I did pay for an hour (or maybe it was half an hour) with a solicitor and told her all our financial ins and outs, and she advised me what I might expect or be entitled to, as well as giving me the benefit of her experience of what some people tended to do etc. (He never knew about this.) This made me feel better as I could make tentative plans for if he did leave. Like you I did have a decent job - in fact was the main breadwinner. I only wish I had confided in my parents at the time because I now know that they would have supported me emotionally and financially and I could have got rid of him earlier and my life would have been so much different. It also would have been different if MN had been around then too. 
I think a lot depends on how he reacts and what he wants - but if you can afford it, I would pay for some legal advice and put a few feelers out about possible jobs. However if you think it is over, then don't let him back - your sons will recover and have a relationship with him too but you need to also think about your own well-being.
I think the best thing to do is to confide in someone in RL - don't feel you have to keep his dirty secret from everyone - choose a close friend of yours or some family member - because you need to have someone by your side.
Also, if it comes to divorce, try to remember that he is no longer your best friend and no longer on your side - he will be on his own side, no matter what he says. There may be a chance for a civil, even friendly, relationship later and co-parenting, but while the divorce is being negotiated, don't take him at his word.
Oh and one more thing, when I did get divorced my parents wanted to help me out with a bit of money, but the solicitor advised us to wait until after the divorce was finalised so as not to muddy the waters - they helped with a bit of cash and buying stuff for the kids etc.
for you OP.