I'm writing out a timestamp to a file on every pass through a loop in my main program (to record when the last data scan was made). I do this so that if the program stops, when it is restarted, it can tell how long the program has been down for.
Anyway, if I open/write/close the file on every loop, I get a flicker of the cursor (from the normal cursor to an hourglass). If I just open the file on the first call, and just write to the file on every loop, I don't get a flicker. But then I need to flush the file on every loop to make sure the data gets written out. Then I get the flicker on the call to Flush.
I tried this using a datalog file and a text file. Is there some other file that I could use that wouldn't cause this behavior? Or is there a way to prevent the File I/O VIs from changing the cursor?
Solved! Go to Solution.
Thanks for the post and I hope your well today.
Pardon if I have mis-understood. Are you opening and closing a file within the loop? The normal structure is to open/create a file>>then read/write within a loop>>then close the reference outside the loop. Open/closing within the loop will slow the loop iteration down.
Could you please clarify your code structure and also what you mean by "make sure the data gets written out".
Hope this helps,
Yes, I open/write/close the file within the loop. I know this slows it down a bit, but the close forces a "flush", so that the data is actually written out to the file. Otherwise, I think the writes are buffered, and the data may not be written until a later time. My other option is to open the file before the loop, then do the write and "Flush File" within the loop. That keeps the file open, but the data is written to the file immediately. But Flush File also causes the cursor to flicker to the hourglass, just as the Close VI does.
The reason I'm doing this is because I have to guarantee that the data gets written out to the file every time the loop is executed, because the system could lose power unexpectedly, and otherwise all the data that is still in the write buffer would be lost.
Excerpt from "Flush File" documentation:
Data written to a file often resides in a buffer until the buffer fills up or until you close the file. This function forces the operating system to write any buffer data to the file.
I had noticed my screen flickering when opening many VITs or closing them. But I only noticed this on my machine. It did not happen on the customer machine (which was a high-end monster). Since it did not happen on the traget machine i did not chace it down further.
Since then I read a thread where disabling
Desktop >>> Properties >>> Appearence >>> Effects >>> Show Window Contents while dragging
was reported to make a difference. I have discovered that my machine has that option set, so it may have had something to do with what I saw, but I can't confirm this theory.
I don't know if that will help but it is all I can offer at the moment.
Thanks for the replies.
Flush File seems fine to use to me. I wonder why the time is appearing, this must mean windows is getting involved - does the flush take a long time?
Im sure you can alter windows cursor settings to turn that feature off..
Are you trying to stop it or find out why it appears?
Thanks for your reply.
I have looked into this more (asked a windows guru :D), and it turns out you cant tell windows to stop it. Maybe the cursor would work, but I believe windows would over-ride LabVIEW.
Windows does this when the program in focus is busy. This must be some aspect of the program usage is large. I would suggest running perfmon (start>run>perfmon). See if the memory of disk usage is spiking at all (at the moments) when the glass appears.
Hope this helps,
I've seen cursor flicker (hour glass) when writing to a file in a folder set to Auto-populate in LabVIEW project. I've attached a project with VI demonstrating this behavior in another post. See here:
Blue Ridge Test, Inc.
Was your folder auto-populating? (See my post right above yours.)
If so, you should not have to remove the file from your project; just put the file in a folder where you can "stop auto-populating".