Error / hangs that occur over an extended amount of time are some of the more difficult to troubleshoot.
The most common reason is the system is running out of memory. When using NI-IMAQ and IMAQ Vision, the most likely reason for the memory usage is the IMAQ Create being inside the While Loop (where is is called each time the loop executes). If you are performing a Grab, the IMAQ Create needs to be on the outside of the While Loop (allocating the memory 1 time, and then reusing it).
I feel fairly confident this is the problem. One way to test this is to run the IMAQ Grab example (High-Level Grab in IMAQ Vision Display) that ships with NI-IMAQ. This will test just the NI-IMAQ functionality.