A method of thermally inhibiting starch or flour is provided. The method involves thermally or non-thermally dehydrating a grain to anhydrous or substantially anhydrous, and then heat treating this dehydrated grain. The heat treated dehydrated grain is then milled, producing thermally inhibited flour and/or starch. Using this method, the shelf life of the resulting thermally inhibited whole grain flour is extended compared whole grain flours that are thermally inhibited after milling.