Arduino restart after plug USB cable. How can I avoid?

Good morning

Suppose that I have my Arduino ON with 12V 2A power unit... Now I plug the USB cable between Arduino and PC... the Arduino will restart...

How can I avoid that?

Please let me know Thanks on advance Best regards Pedro Ferrer

Good morning

I've found here the answer.,60640.msg438466.html#msg438466

Also it works to to Arduino Mega?

Thanks Best regards Pedro Ferrer