11-21-2008 01:29 AM - edited 11-21-2008 01:30 AM
Hi,
Sorry, I guess the answer was already... You don't need to play with DLLs etc.
Just place Open/Close file functions out of loop:

Andrey.
11-21-2008 03:26 AM
Really nice work, Andrey!
This behaviour is obviously in fact created by a blocking call to the UI thread made by the popup. I searched a little in google (it is your friend!) and found in a .NET forum the following statement:
"Worse, if another thread calls .Invoke on a UI object owned by the blocked thread, the thread too will be blocked."
So it seems that Open/Create/Replace File.vi executes a call to the UI thread even if a filename is connected to its input. I don't know if this is intended, but it definetly blocks if another thread already made a similar call to the UI thread.
Andrey's solution is the recommended way to work with files if each iteration has to work with the same file. So please stick to this.
hope this helps as a first solution,
Norbert
11-21-2008 03:37 AM
Thanks, Norbert.
Yes, here some interference with UI thread. The only interesting point is following: Open File blocked by File Dialog only. This function not blocked by calling OneButtonDialog, even not blocked by calling DLL in UI thread (which normally block all threads in UI mode). This fact can position this as "bug" and should be investigated by NI R&D.
Andrey.
11-21-2008 03:58 AM
Andrey,
i think that the problem occurs because the file dialog is the windows file dialog which is called by the path browse button as well as the create file.vi. So i asume that there is no block of the UI thread itself, but with the file dialog from windows. I think it is possible that the lock due to the dialog does not occur if the calls to this dialog are located in different process (OS processes), but i am not sure.
Norbert
11-21-2008 05:10 AM
11-21-2008 05:10 AM
11-21-2008 06:12 AM
I agree with Wiebe, it actually means that using 'Open File' is a no-no.
Ton
11-21-2008 06:49 AM
One very annoying issue of this bug is, that the code pieces that block each other via the UI thread bottelneck do not need to share any dependencies (e.g. a front panel browse operation and a background logging process). That makes them very hard to debug (worse than those ugly race conditions). And the presented bug-inducers are not some exotic functionality, but very common to occure in parallel (dll call and File I/O and property nodes!).
I would really like to see that bug fixed, or at least have some tool to monitor the UI Thread bottleneck.
I now remember that on the case I struggled with that bug, I used a semaphore to pause the background polling process during file I/O. Not a nice workaroun, though.
Felix
11-23-2008 03:24 AM
May I know how does experts make log into file normally, since I have many places in many vis need to be logged. Some vis are dynamically called out.
Thanks.
11-24-2008 04:40 AM