If your dog pesters you for petting when you need to be doing something else, break off visual contact with him. You can use your torso to push him away with a body block (remember not to use your hands) or turn your head away (chin raised) in a benevolent but royal dismissal. It’s amazing how fast dogs will go away if you break off visual contact with them. It’s equally notable how hard it is for us humans to do that when we’re trying to get our dogs to do something.