LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

trying to suspend execution

Hi
I am getting the following message box error...
"A non-debuggable thread is trying to suspen execution at address 7C901230.  Do you want to suspend execution?"  I get this error only when trying to use some WORD activeX controls to make a report.  The error occurs when the program is closing, i.e after quit userinterface, after any other close up stuff, after the code hits the last "}" in main.
If I don't call the Word report code, I don't get the error.  I am using WORD 9.0 OL.
Any ideas on how I can find what is causing this error?
thanks
0 Kudos
Message 1 of 6
(3,858 Views)
sorry, that was CVI 8.1, and it doesn't matter if it is running in the debugger, or as a released version
0 Kudos
Message 2 of 6
(3,855 Views)
bglat-

Sounds like maybe you're not getting the ActiveX server for Word shut down before you're terminating your process.  The C runtime is probably notifying the ActiveX Server object that the process is terminating, and that is going to leave it hung up (suspended).  When you return from main, the C runtime environment is making a TerminateProcess () system call on your behalf, and the TerminateProcess logic is doing the suspend notification to the Word ActiveX server object.  I suspect the reason Windows does a popup error message is because if the thread running the ActiveX server gets suspended, and there aren't any other references to the Server Object, how would it ever come out of suspension - it would sit there forever, conceivably.  Though if the reference count on a handle goes to zero, the OS should kill the object for you.

Are you making this call before you terminate your process?

iStatus = WordRpt_ApplicationQuit (hWord, WRConst_SaveChanges or WRConst_DoNotSaveChanges or WRConst_PromptToSaveChanges);

Plus, you should discard the handle with

CA_DiscardObjHandle (hWord);

But as the process terminates, this will happen automagically. Just don't try to reuse the handle once you've shut down the word server.

We used to have trouble in this area with Excel and ActiveX from CVI - Excel would stay running even as we quit the process.  I think NI fixed some things up to make it shut down properly some years ago.

Menchar


0 Kudos
Message 3 of 6
(3,836 Views)

yes, I am quitting the app and discarding all handles with the functions that you mentioned.

If I  call my make_report() function twice, without leaving the app, the first report looks ok, but the second has lots of strange characters.

If I turn on Task Manager, I can see WinWord.exe come and go off the process list, but I still get the error message.

Know of anything else that I can try?

0 Kudos
Message 4 of 6
(3,834 Views)
bglat -

Well, all I can tell you is that we use the Word Report ActiveX server without seeing this problem, but we don't handle multiple documents in the same session, we shut the ActiveX server down completely after each report is generated. In fact, the process is terminated and restarted each time too.

You might try shutting down the server annd restarting it for each report, and if that doesn't help, bundle up the report generation into its own process and let that process terminate after generating the report, then restart it for your next report.

But, you shouldn't have to be doing this.

This issue I guess could conceivably also be sensitive to OS / Word version issues.  We're running WinXP SP2, and Office 2003 SP2.

I've attached some code that works for us.  It fires up word report, opens a document, runs a Word macro on the opened doc, the saves the doc, and quits word report.

Menchar


0 Kudos
Message 5 of 6
(3,830 Views)

I tried running the Word app in a separate thread and it works much better, .. no problem with suspending the execution.

Thanks for the great idea.

0 Kudos
Message 6 of 6
(3,786 Views)