Hello,
I’m calling an asynchronous method that uses a DataRequestMonitor. This method returns a set of variables
Calling this method in Run mode : I get empty set
Calling this method in debug mode and stepping in : I get a set with correct values
So in Run mode i used “Thread.sleep” to solve a problem of conflict between threads (a simple reflection)
But it is not a good solution
My question is
how could I complete an asynchronous method call and get returned values without setting a Thread.sleep ?
My piece of code :
final ArrayList<IExpressionDMContext> children = new ArrayList<IExpressionDMContext>();
IExpressions expressionService = fServicesTracker.getService(IExpressions.class, null);
DataRequestMonitor<IExpressionDMContext[]> drm = // the used DataRequestMonitor
new DataRequestMonitor<IExpressionDMContext[]>(fSession.getExecutor(), rm) {
protected void handleSuccess() {
children.addAll(Arrays.asList(getData())); (1)
//children here are not empty
}
};
expressionService.getSubExpressions(miDMCExp, drm); // call of the asynchronous method
//children here are empty
In handleSuccess() method normally (as I understood) the calling of the asynchronous method is completed.
And so in (1) I get all searched data.
But in (2) the filled “children” is empty.
Is there any wrong use the asynchronous method ? is something missing ?
Thanks for any help