Preventing a menu item from being pressed twice
For long tasks you should use Drupal's Batch API. It takes a bit to learn, but has these benefits.


The user will be taken to a separate page with a progress bar.
You can display a custom message explaining what you are doing.
If you can break your task into discrete chunks that can be performed in separate requests that will ensure that you won't run into any php timeout issues and the users will see their progress.


For example, during Drupal setup you see the following batch process: