There are a lot of strange grammar solutions in the code. It is part of VideoInput library by Evgeny Pereguda: http://www.codeproject.com/Articles/559437/Capturing-of-video-from-web-camera-on-Windows-7-an. I made only functionality changes, no refactoring.