Hi Gary,
Thanks for submitting this test program. This does make things easier.
I tried it in two different computers, with two different printer setups. I was able to reproduce the 5 second delay in one of them, and not in the other, which makes me suspect that it does have something to do with the printer driver (both computers were Windows XP).
I debugged the delay and found that it was happening in a particular call to the printer driver. Unfortunately, it's happening at a point in our internal code in which we're holding on to the UI lock. This means that other threads are, in fact, blocked from performing UI operations, including function calls to the User Interface Library, or responding to low-level messages, such as mouse clicks, or redraw events. This explains why the other threads are blocked. They're blocked, probably, at the point where they need to call SetCtrlVal, or some other function.
Assuming that your main thread needs to perform UI operations, then you'll need a different solution in order to print your charts. I took the liberty to take your test program and modify it a bit, such that printing now takes place in a separate process altogether. I still create a separate thread in the main program, but this thread does not do any UI, so it should not interfere with the main thread. This thread writes the data to a file, then launches the separate process, waits for it to finish, and then deletes the file. This separate process starts up, reads the data, loads the main panel and copies the chart to a separate panel for printing, and then performs the same plotting/printing loop as before. I'm attaching this program here.
In the meanwhile, we're going to research the feasibility of releasing the UI lock around the specific call that is causing the delay. I'm not sure what exactly causes the delay, but as long as the thread isn't holding the UI lock, it will not block other threads from making UI calls during the delay. Assuming that there is no problem with doing this, we should have it ready in time for the beta program of the next CVI version, which should be available soon. If you'd like to try it out, sign up for it in
ni.com\beta.
One last thing: in your example, the chart is overlapped by the legend (as you described in the other forum thread) and by the control label. You should know that the plotting speed of charts and graphs are significantly impacted when the plot area is overlapped by other objects. If overall plotting speed matters to you, you might want to consider moving these items to a different location.
Hope this helps,
Luis