LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cursor flicker when closing or flushing a file

Solved!
Go to solution

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?

 

 

0 Kudos
Message 1 of 15
(3,519 Views)

Hi mvickerman,

 

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,
Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 2 of 15
(3,500 Views)

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.

0 Kudos
Message 3 of 15
(3,494 Views)

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.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 4 of 15
(3,488 Views)

Hi All,

 

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?

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 5 of 15
(3,476 Views)
I definitely want to stop it.  I don't know how to set it so that the hourglass doesn't appear.  I thought I could get around it by explicitly setting the cursor in LabVIEW, but whatever is happening in Flush File (or Close file) still sets it to the hourglass for a short amount of time.
0 Kudos
Message 6 of 15
(3,470 Views)

Hi mvickerman,

 

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, 

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 7 of 15
(3,443 Views)

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:

 

http://forums.ni.com/ni/board/message?board.id=170&thread.id=374978

 

-Jason

 

Blue Ridge Test, Inc.


Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
0 Kudos
Message 8 of 15
(3,397 Views)
Solution
Accepted by mvickerman
Found out what the problem was.  The data file that I was writing to was included in my LabVIEW project.  So I guess it was trying to update the project every time I updated the data file.  Once I removed the data file from the project, everything was fine -- no hourglass flicker on the cursor.  Thanks for all the replies.
Message 9 of 15
(3,393 Views)

mvickerman,

 

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".

 

-Jason


Certified LabVIEW Architect
TestScript: Free Python/LabVIEW Connector

One global to rule them all,
One double-click to find them,
One interface to bring them all
and in the panel bind them.
0 Kudos
Message 10 of 15
(3,389 Views)