1. While they made fun of my pose, some students posted a lot of unkind comments.

2. Some students posted a lot of unkind comments while they made fun of my pose,
-------------------------------------
Thank you for your help. Are both the same in meaning?

===============================
3. When/While he was playing the piano, she came in.

4. When/while he played the piano, she came in.
----------------------------
What is the difference between them?
Can we use both 'when' and 'while'? Are both the same in meaning?
Does #4 mean:When he started to play the piano, she came in? (almost at the same time)

I wouldn't use "while" in either 1 or 2. I'd use "Because" in sentence 1 and "and" in sentence 2.

3 and 4 are correct. The only difference between them is the particular tense used in the dependent clauses -- past progressive in 3 and simple past in 4.