in my apex code I need to do some calculation only when future method has executed I tried below code to check if future method has executed:
public static void anotherMethod() {
while('Completed' != checkFutureMethod()) {
checkFutureMethod();
}
// need to do something here only when future method has executed
}
private static string checkFutureMethod() {
string asyncApexStatus;
for(AsyncApexJob asyncApex : [select Status From AsyncApexJob where ApexClass.Name = 'classname']) {
asyncApexStatus = asyncApex.Status;
}
return asyncApexStatus;
}
but still the above doesn't wait future method to finish, please suggest.