getting IllegalStateException on IInteropManager
Hi,
I'm invoking a method through IInteropManager, which checks for the presence of sync rule. I used the method findSyncRulesByExternalTypeNameAndProjectArea() on IInteropManager...I'm getting IllegalStateException on its call.
(The reason is because of a check in ThreadCheck class' checkLongOpsAllowed() method).
Although it works fine, and returns the array of sync rule handle correctly, so that I can check for the presence of sync rule, it does log the above mentioned exception on the console.
I checked with jazz.net forum (https://jazz.net/forums/viewtopic.php?t=649&sid=df6d35b5d3505e01ae822b4b62810756), applied the suggested solution of creating a separate job and calling such methods from within the scheduled job, but the problem with this approach is that the new job created is scheduled alongwith the synchronizer, thus we do not get its result while synchronizer is running.
Have gone through following jazz links:
https://jazz.net/forums/viewtopic.php?t=1339
https://jazz.net/forums/viewtopic.php?t=2297
https://jazz.net/forums/viewtopic.php?t=649
Also, tried to creating a separate thread and calling the method, it too didn't work.
Any pointers?
I'm invoking a method through IInteropManager, which checks for the presence of sync rule. I used the method findSyncRulesByExternalTypeNameAndProjectArea() on IInteropManager...I'm getting IllegalStateException on its call.
(The reason is because of a check in ThreadCheck class' checkLongOpsAllowed() method).
Although it works fine, and returns the array of sync rule handle correctly, so that I can check for the presence of sync rule, it does log the above mentioned exception on the console.
I checked with jazz.net forum (https://jazz.net/forums/viewtopic.php?t=649&sid=df6d35b5d3505e01ae822b4b62810756), applied the suggested solution of creating a separate job and calling such methods from within the scheduled job, but the problem with this approach is that the new job created is scheduled alongwith the synchronizer, thus we do not get its result while synchronizer is running.
Have gone through following jazz links:
https://jazz.net/forums/viewtopic.php?t=1339
https://jazz.net/forums/viewtopic.php?t=2297
https://jazz.net/forums/viewtopic.php?t=649
Also, tried to creating a separate thread and calling the method, it too didn't work.
Any pointers?
Accepted answer
You can just call the Job.join() method to wait for the job to finish. In other words, doing
will run the code in the job in a non-UI thread, but block until it completes. You can arrange for the return value of the method you want to call to be passed back as an attribute of the Job object you create.
Job job = new Job(name) {...};
job.schedule();
job.join();
will run the code in the job in a non-UI thread, but block until it completes. You can arrange for the return value of the method you want to call to be passed back as an attribute of the Job object you create.
One other answer
thanks a lot John, it works!
You can just call the Job.join() method to wait for the job to finish. In other words, doing
Job job = new Job(name) {...};
job.schedule();
job.join();
will run the code in the job in a non-UI thread, but block until it completes. You can arrange for the return value of the method you want to call to be passed back as an attribute of the Job object you create.