cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Translate the entire conversation x

How to run tasks in background (Creo Object Toolkit - Java)?

GS_14113977
3-Newcomer

How to run tasks in background (Creo Object Toolkit - Java)?

We are working on building a Creo application using Object Toolkit Java.

One usecase of our application is to execute tasks in background (such as authentication flow, upload opened model) while displaying progress (using animated gifs) on the custom UI created using Creo UI editor.

 

As per our observation, whenever we start a task in background by creating a new Thread in Java, it blocks the currently open UI dialog i.e the UI dialog completely freezes and doesn't display anything.

The result is same for all modality types for a dialog - MODAL, MODELESS and WORKING.

 

Sample code snippet:

 
uifcComponent.CreateDialog(UPLOAD_DIALOG, UPLOAD_DIALOG);
uifcDialog.DialogFind(UPLOAD_DIALOG, UPLOAD_DIALOG).SetModality(DialogStyle.DIALOG_STYLE_WORKING);
uifcComponent.ActivateDialog(UPLOAD_DIALOG);
Thread backgroundThread = new Thread(() -> {
    // Background tasks

    // Destroy dialog once background task is complete
    uifcComponent.DestroyDialog(UPLOAD_DIALOG, UPLOAD_DIALOG);
}, "thread_name");
backgroundThread.setDaemon(true);
backgroundThread.start();
 
Is there a way to keep the UI active and display some progress using animated gif while something is running in background?

 

cc: @RJ_11007702 

ACCEPTED SOLUTION

Accepted Solutions
RPN
17-Peridot
17-Peridot
(To:GS_14113977)

In synchronous you use share the event loop with Creo, even if you would create another thread, you may not called, and by the way this kind of program is not supported by PTC. 
You need an asynchronous connection and your own event loop, here you can do what even you like. But even in this mode multiple threads may an issues, it depends which thread tries to do something in Creo. 
On top your own event loop may blocked (during EventProcess) on some actions in Creo, for example if the user edit parameters. 
That’s all my 2 Cents based on your questions or assumptions 😵💫

 

View solution in original post

2 REPLIES 2
RPN
17-Peridot
17-Peridot
(To:GS_14113977)

In synchronous you use share the event loop with Creo, even if you would create another thread, you may not called, and by the way this kind of program is not supported by PTC. 
You need an asynchronous connection and your own event loop, here you can do what even you like. But even in this mode multiple threads may an issues, it depends which thread tries to do something in Creo. 
On top your own event loop may blocked (during EventProcess) on some actions in Creo, for example if the user edit parameters. 
That’s all my 2 Cents based on your questions or assumptions 😵💫

 

Hi @GS_14113977,

 

I wanted to see if you got the help you needed.

If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Of course, if you have more to share on your issue, please pursue the conversation.  

 

Thanks,
Anurag 

Announcements

Top Tags