# Time constraints on KernelExecute commands or MenuItems?

I'm trying to use Get to load some pretty substantial packages from a custom menu in the Mathematica toolbar (added via MenuSetup.tr).
The problem is, the standard 5-second evaluation timeout seems to apply to commands executed with KernelExecute, so only a fraction of my Get is evaluated before the command times out.

I'm wondering whether there's an option that can be passed to KernelExecute (or to Item / MenuItem) that will remove that time constraint so that my command can be executed completely.

-

As of version 9, MenuItem now takes the Method option, similarly to Dynamic and Button. Which means that you can make it a "Queued" evaluation. To demonstrate:

FrontEndExecute[
FrontEndAddMenuCommands[
SystemKernelExecute[Pause[10]; NotebookCreate[]],
SystemMenuEvaluator -> Automatic]}]]


Here we have a command which adds a new menu item after the "Open" menu item which waits 10 seconds, then opens a notebook. And it fails. Similar to what you're seeing. So, let's reset the menus:

FrontEndExecute[FrontEndResetMenusPacket[{Automatic}]]


and add it again, but this time with the Method option:

FrontEndExecute[
FrontEndAddMenuCommands[
SystemMenuEvaluator -> Automatic, Method -> "Queued"]}]]

This has all the same features and limitations of the "Queued" usage elsewhere. For example, if you have a bunch of Shift+Enter evaluations in your queue, this goes to the back of the line and waits for those.
Fantastic! This allows my menu to function precisely as intended. It's also worth noting that Method->"Queued" also seems to allow kernel-blocking dialogs such as InputDialog to run from within MenuItem` without hanging the frontend. –  bdot Nov 2 '13 at 20:02