fixed repeating the same task if processmessages inside handler