This content has been marked as final. Show 1 reply
If you spawn a new thread to do work, you should use another application module than the one you use for the UI. The way I do this is to call a method in the am which then spanws the new thread which then gets a new root application module and the thread uses this ma exclusivly. All changes done in the thread are part of the transaction of the am used in the thread. There can't be any communication with the transaction from the am used in the ui. The ui only can react on changes done in tables in the db. The spawned thread uses a semaphore which only allows one execution of the thread until the thread has done its work. Here you have to be careful if your app runs in a cluster environment. In this case the semaphore has to be stored in the db or an a shared file system.
One other way to do this (more easily) is to implement hte log running process as an asynchronous web service. then you call this service from your UI and let the service do the work. Via the callback you get notified once the service has finished.