Showing results for 
Search instead for 
Did you mean: 

producer consumer loop

Go to solution

I have a Producer consumer loop that is  reading in data from a Excel File call sample1. There is a third party software that constantly writes data to the same excel file Sample1 every _ amount of seconds. Every time the Third party software writes it will over write the excel file data. So it may only be 5 columns and 3 rows.



1. I need to make sure that there is not a conflict when the Third party software has the file locked to read and Labview is trying to read.

2. I need to make sure  that if labview isn't reading and reading before the Third party software writes so basically i need some way of checking labview isnt reading the same data twice i need to make sure the file has been updated before it tries to read again. The problem comes in when you can't regulate the time that the third party software reads.





0 Kudos
Message 1 of 5

You can try something like this in a loop:




It looks at the file and when it sees its modification time changed (meaning something was written to it) it copies it (so that you don't touch the shared file) and then it reads the data from the copy.


Try to take over the world!
Message 2 of 5
Accepted by topic author *E*

I've had to write code for similiar applications.  It is tricky.


Have a look at the .NET FileSystemWatcher.Changed Event.  This might be a good way to monitor what is happening with the file.



 Take a look at this post:


"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
Message 3 of 5

tst Thanks for that quick reply.



would i do this in my producer loop? do i remove what i currently have in the case structure of the producer loop?

0 Kudos
Message 4 of 5

vt92  Thank you also for your input i will check out your link now.

0 Kudos
Message 5 of 5