The Stochastic Dynamics Of Systems In Switching Environments