bpy.app.background

If I use this command in panel this is always “false” state. Because blender panels are only updated when the blender window is active. Where I can put this command that it could listen it even if blender is in the background. Many thanks.