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?
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.
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(() =>
//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 ?
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
From the Tecnomatix.NET help file:
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.