This really depends on what the while loop does. If it's say, something to the effect of:
Code:
int i = 0;
while(i < 10) {
i++;
}
then certainly you can do it. If, instead you're doing something relying on external sensors/states. For example, in pseudo code:
Code:
while(button is pushed) {
do stuff
}
then you won't get anywhere because whether or not the button is pushed isn't going to be updated within your function (that updating in some of the FIRST-provided code which you don't need to and shouldn't modify; but, if you're curious you can look). If your code doesn't let the program flow continue to the FIRST-code which updates buttons you just won't have the new status of the button being pushed (and as a result you'll be stuck).
It's probably worth noting that your user code is already in a big while loop (the one you rightly pointed out is in the main function) and as a result already will be called repetitively.