It is irrelevant if the work is electrical, mechanical, chemical... or if done suddenly or slowly, as long as it is performed in an adiabatic way, that is to say, without heat transfer into or out of the system.
Ogenj npr.