An electric fence for deterring animals from an area with one or more supplies of feed and at least one separate feed processing machine, wherein the fence comprises an electrically conductive member, an electric power supply connected to said member for energizing the member and arranged to provide an electric shock to an object coming into contact with said member. A controller is operatively connected to the fence, wherein the controller is arranged to measure a value of an electrical parameter of the fence, and to automatically adjust the operating state of the machine within the area when the measured parameter value fulfills a predetermined criterion.