I am trying to build a windows forms application using .net and collect some information from the .prt files selected by the user (For example user attributes). Great care is taken not to mess around with any "Display" related NX Open APIs. NX Open Batch programs documentation helped a lot.
In this scenario is there a way to update the windows form with a progress report (a short message at predetermined locations of the program to update a list box) ?
Backgroundworker... (Multithreading or running NX in a background thread is not possible. Fair reason..). This method does work the first time very well. UI starts...user button click..start a backgroundworker to do NX operations...use worker.reportprogress() at necessary locations and the UI updates accordingly (list box with frequent messages like.."open part success", "close part success" etc.,)
Keep the UI alive (after clearing all the controls) and user button click again...NX reports "SM function called from wrong thread" ! How does it work the first time...I do not know!
EventHandler...(The UI does not update until NX completes its operations and returns the control back to the UI)
Also the UI freezes up the moment open_part is called and goes into "Not Responding" until NX finishes its work.
Any ideas will be helpful.
I am using NX 10 and C#. Please let me know if more information is required.
Thanks and Regards
I agree with you, Backgroundworker don`t want to start all NX processes, only System methods are work correctly.
But I see no one answer for your question - maybe you solve this problem?
It`s very interesting for me.
If you scan this forum for the topic "busy dialog" you will find a post I had about creating a WINFORM dialog used to show progress and allow the user to ABORT.
Maybe this will help you too.
No, I do not have a solution to the backgroundworker problem. (As of now it runs the first time correctly and If I have to keep the winform alive for another round of processing I have to Application.restart())
I had a short look on the post mentioned by you. It says "query the class to find the value of the flag". I am not sure if I understand this correctly. Can you please maybe help me with a few lines of code on how to do that? It would be of great help to me. Thanks!
That BUSY DIALOG post had two aspects to the WINFORM dialog
- progress of processing
- STOP or ABORT the processing
Since you don't need the STOP capability, you can ignore the lines concerning the STOP ability (which is the line you had mentioned).
If you want to use multi-threading, all of the NX Open work must happen in the main thread. Could you redesign your application so that the Windows form processing is handled in a secondary thread, and the NX Open calls are in the main thread?