On the possibility of measuring the electron spin in an inhomogeneous magnetic field