It usually takes about 4 months for the COS. You may resign after the H-4 is approved. You would be out of status if the H-4 COS is denied and you failed to maintain your employment under the H-1B Petition.