Cancel
Showing results for 
Search instead for 
Did you mean: 

does PS .net support multi thread programming?

Creator
Creator

I got a time consuming process, so i want to put it into another thread, but PS just collapse without any erro information. Does PS .net support creating a new thread?

 

6 REPLIES 6

Re: does PS .net support multi thread programming?

Siemens Legend Siemens Legend
Siemens Legend

Process Simulate runtime environment should be assumed to be single-threaded.

For example, if you are using any ITxObject, or the TxApplication singleton to access or modify the PS runtime model from a different thread other than the main thread - you will probably get a crash due to concurrent access to shared resources.

 

That being said, creating threads is possible in the .NET environment, just as long as you make sure not to update or read any information from a Tx object. Typically I might use a worker thread for handling communication (e.g., listening on sockets), but always make sure that there is a thread-safe message queue used between the worker thread and the main thread - which is the only thread to access the PS runtime model.

 

What exactly is time consuming about your process?

If you share more details about what you are trying to compute/collect, the community might come with other suggestions how to optimize it.

Re: does PS .net support multi thread programming?

Valued Contributor
Valued Contributor

Hi There,

 

I am also facing an issue while using thread. Bascially I am reading all the objects (e.g GetTxDocumentData()  ) and there properties and excuting in under TxButton command execute method. During execution want to show progressbar and run the GetTxDocumentData() in different thread and show the progressbar.

 

But when running different thread

 

backgroundThread = new Thread(
new ThreadStart(() =>
{
      GetTxDocuumentData();
 
));
backgroundThread.Start();

 

 

void  GetTxDocuumentData()

{

       //logic to read all object and propeties info

}

 

Getting an runtime exceptions , with error heap currouptions.

 

If I don't run the GetTxDocuumentData() in thread ( with freezing UI )  it works fine 

 

Any idea how I can fix that ?

 

Regards,

Sandeep

 

 

Re: does PS .net support multi thread programming?

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer

I don't think so. All calls to the API must be done from the mother thread (the one that runs your TxCommand instance) as already said in the previous post.

If you want to keep your UI reactive you can use the async - await mechanism of the .NET Framework, this could do the trick

Highlighted

Re: does PS .net support multi thread programming?

Legend
Legend

From the Tecnomatix.NET help file:

Threading
The Tecnomatix.NET SDK does not support multithreading.
 
But I will also try to work with async/await to avoid UI freezing.

Re: does PS .net support multi thread programming?

Phenom
Phenom

@sandeepmore 

 

Have you tried using Application.DoEvents()? If your progressbar is based on a customized for loop, you can add it inside the loop to refresh the graphical interface.

 

Regards, 

Re: does PS .net support multi thread programming?

Legend
Legend

Hello!

I have faced the problem with multithreading during developing of WPF dialog, that must end modeling for 10 to 20 components. This takes some time. The GUI was developed with WPF and WPF freeze GUI until dispatcher thread executes any code. So, in order to display progress status I have relocate the execution in another task. I have wrote this for a year in Pattern for WPF with time-consuming operations

 

Best Regards,

Witalij