debouncing a switch during 'while' loop

Did I integrate this correctly?

No. The while statement needs some conditional statement in the parentheses, not all the stuff you put there.