Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Good day to all!
I'm working on a plugin, which execution time can be quite a long.
So I'd like to add progress bar into my plugin, so users can understand that everything's ok, plugin is working and no need to panic yet
In Object Toolkit UG I found section: 7. User Interface Foundation Classes for Dialogs
There I found uifcProgressBar class
So I opened Creo UI editor and it's UG, created simple Dialog with only Progress Bar in it. Saved .res file, put it into my plugins directory, added necessary code in the project.
Dialog appears, that's cool!
After that I get pointer to my Progress Bar object.
Now I'm stuck. Progress bar all the time shows 50% completeness. I can't figure out how to launch it in an infinite loop and how to stop it afterwards.
It would be awesome if someone can help me with advise to go through this.
My code:
xint status = uifcCreateDialog("Dialog1", "Dialog1");
if (status == 0)
{
uifcDialog_ptr dialog1 = uifcDialogFind("Dialog1", "Dialog1");
uifcProgressBar_ptr pbar = uifcProgressBarFind("Dialog1", "ProgressBar1");
if (pbar)
{
pbar->SetUnbounded(xfalse);
}
Dialog1DialogListener *dialog1Lis = new Dialog1DialogListener();
dialog1->AddActionListener(dialog1Lis);
status = uifcActivateDialog("Dialog1");
Mostly I took it from cxx file generated by Creo UI editor and added some rows related to uifcProgressBar_ptr later.
Thank you in advance,
Artem
pbar->SetUnbounded(xtrue);
solved a problem...
Also there are few methods to set int value to a progressbar.
Guys,
Can you please help me to figure out how to manage threads to get progressbar working?
I'm trying to launch plugin's main method in a thread using std::async and than activate window and after I'm trying to get() result of main method, but it's not going through before i close progressbar.
Code:
auto res = std::async(std::launch::deferred, parse);
...
status = uifcActivateDialog("Dialog1");
...
auto resCode = res.get();
if (resCode == ...)
Thanks,
Artem
Hi all,
I figured out how to launch my main procedure within a separate thread:
std::thread t1(main_proc);
//activate dialog window with progress bar
t1.join();
This seems to be correct, but when t1.join() is not placed right after t1 initialization - Creo Parametric catch an error and terminated unexpectedly.
Using debugger I found out, that error appears during call session->GetCurrentModel() or solid->ListFeaturesByType(1) or some else methods in a separate thread.
This seems strange to me, because as far as I understand from UserGuide, there should no be any issues with multi-threading in Creo objectToolkit:
Multithreading is now always supported in PTC Creo Object TOOLKIT C++
applications, without the need to call the multithreading method, when the
application creates additional threads for processing.
maybe someone had faced this problem?
Thanks,
Artem