I heard from one of my friend once that told me that when I'm consuming whey protein, I shouldn't also consume mass gainer. Can consuming these two together be harmful? If so, how long should I wait after consuming one to have the other?
You're essentially asking if you can eat food and then eat more food. Whey protein and mass gainer at the most basic level are: carbs, proteins, and fat. In the case of mass gainer, it usually has large amount of both carbs and protein. So, yes, you can consume them at the SAME TIME, just as you can consume 2 or 10 cheeseburgers at the same time. The underlying question I believe you intended to ask was, "What is the value/repercussions in doing so?" And, the not so simple answer is, it depends
It depends on your target Calorie consumption. Are you aiming to intake 2000 calories or 5000? How many calories are you burning during your regular activities and during your athletic activities? If you're looking for optimal muscle protein synthesis, you would be more interested in BCAAs - specifically Leuceine.
I can tell by your question that you're a novice with regards to nutrition, and a single forum post will not suffice. Please google "Jordan Feigenbaum". He has written extensively on nutrition in the setting of weightlifting. As always, read everything with a critical eye. Best of luck.