I use window switching a lot in my project and I used to have a lot of issues. Sometimes when I tried to switch modes or resolutions, nothing happened, however I never had a video card throw an exception. If it helps, here is what I use in my current application and it works every time. Let me know if it helps, I guess I am waiting a lot longer than 1 frame, but rather 20 frames.

Code:
if(window_positions[16] == 7){
	video_switch(7,0,2);
	wait(20);
	adjust_chat_window_startup();
	str_cpy(strOptionResolution, "800 X 600");
	}

	if(window_positions[16] == 8){
		video_switch(8,0,1);
		wait(20);
		adjust_chat_window_startup();
		str_cpy(strOptionResolution, "1024 X 768");
	}
	
	if(window_positions[16] == 88){
		video_switch(8,0,2);
		wait(20);
		adjust_chat_window_startup();
		str_cpy(strOptionResolution, "1024 X 768");
	}
	
	if(window_positions[16] == 9){
		video_switch(9,0,1);
		wait(20);
		adjust_chat_window_startup();
		str_cpy(strOptionResolution, "1280 X 1024");
	}
	
	if(window_positions[16] == 10){
		video_switch(10,0,1);
		wait(20);
		adjust_chat_window_startup();
		str_cpy(strOptionResolution, "1400 X 1050");
	}
	
	if(window_positions[16] == 12){
		video_switch(12,0,1);
		wait(20);
		adjust_chat_window_startup();
		str_cpy(strOptionResolution, "1920 X 1080");
	}




Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com