The evaluation of the time of day was just an example. What really happens inside the State 1 is a code that will open a File Dialog and allow the user load a ascii file. Nevertheless, if the user closes the File Dialog the "open file operation" is cancelled and is no longer necessary to run State 2. This is the real situation. I would like to use the producer loop just to enqueue elements and not do any kind of evaluation or operations inside it.
I did a very simple test. I got the VI that I attached to the first message of this thread and put a Flush Queue inside State 1 and executed the VI in Highlight Mode. At the time that the State 1 flushed the queue, it was able to flush the State 2 out, but not the Idle. So, even with the Flush operation the Idle case was executed after State 1. I know that in the real speed execution, the enqueue operation of the For Loop is very very very fast and even if the user closes the File Dialog quickly, the whole enqueue operation by the For Loop would be done at that time. But, I think that is dangerous to let the code like that with the assumption that the For Loop will be always faster than the action of the user closing the File Dialog.
Because of that, I would prefer to add a semaphore to make sure that the whole enqueue operation by the For Loop would be complete, before the State 1 start running. What is the best design for the semaphore code you think best applies for this code?
Thanks
Dan07
Message Edited by dan07 on 04-17-2010 04:05 PM