LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dequeue element times out even when queue element has new data

Solved!
Go to solution

Hi,

 

I am using a producer/consumer set up and I am only getting one-iteration from my consumer loop.  I have probed the cluster wire that feeds the enqueue element of the producer and there is a continuous data stream there.  I have a timeout wired to the dequeue element in the consumer loop and have tried different times from 1ms to 1000ms.  It is currently at 25ms.  There has to be something else that is causing this issue, but I am overlooking it.  

 

I also tried adding an event handler that would detect a value change in the data.  That didn't do anything.  I have tried to restart my machine to no avail.  I am about to shut down and take the battery out of my laptop and reboot (the act of a man out of options).

 

If anyone could help, I would be indebted. 

P Gnu

If you want to increase your success rate, double your failure rate.
0 Kudos
Message 1 of 4
(2,821 Views)
Solution
Accepted by topic author PGnu

Hi P Gnu

 

Why are you putting an event handler in the consumer loop ? Moreover there is no time-out for the event handler (default is -1 which implies that the execution of the loop will be suspended till an event occurs and hence the iteration of consumer loop is 0). You could just use a local variable for the stop control to detect the change in stop value.

 

 

Message 2 of 4
(2,814 Views)

Thanks Javed_H

 

I thought that I tried that, but either I didn't or I did it while there was another bug.  At any rate, the time-out on the event handler did fix it.  I appreciate your help.

 

The reason I am using an event handler rather than a local variable is because I have been told many, many times that the local variable is somewhat of a hack.  They gave me other reasons, although they escape me now.  I do recognize and agree, however, that the local variable would work.  I'm letting the design asthetics of others dictate my code.

 

Thank you for your input,

P Gnu

If you want to increase your success rate, double your failure rate.
0 Kudos
Message 3 of 4
(2,808 Views)

Glad to know your problem was resolved.

 

I agree that local variables should be avoided. However the manner in which you are using event handler is not the correct way to stop the consumer loop.

 

Another approach would be to connect the error terminal to the loop condition of the consumer loop and move the close queue function block after the producer loop. In this manner once you click on stop, the producer loop will stop and close the queue reference due to which an error will be generated in the dequeue element block and this will stop the consumer loop.

0 Kudos
Message 4 of 4
(2,801 Views)