# Revision history [back]

### how can i instead of waitkey in MFC

We use MFC to play a video.

We can not use waitkey and sleep in main(UI) thread.waitkey and sleep will block main(UI) thread.

If we not use waitkey  and sleep,how can i control video playing with different FPS.
1.Can we update UI and video output in other thread(I think it is not a good idea)?
2.Waitkey or sleep in main(UI) (I think it is not a good idea)?
3.Should we PostMessage from other thread to UI thread(is it the best solution)?
can message guarantee the refresh interval?


Reference:

The function waitKey() waits for a key event infinitely (when delay <= 0) or for delay milliseconds, when it is positive.

If the FPS is equal to 20, then you should wait 0,05 seconds between the consecutive frames. So put waitKey(50) after imshow() and it will be displayed at normal speed.