function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jamz_2010Jamz_2010 

@future problem

Hi all,

 

I currently have a method which simply calls an @future method 10 times. The method that it calls updates the database and stops. The problem is that the first methods dataset doesn't appear to get updated when the @future method fails. I have tried adding a wait to the code by using:

 

 

 

while (iCount < 10) {

runFuture();

 

Double dMilliUntil = System.Now().millisecond() + 100;

while (System.Now().millisecond() <= dMilliUntil ) { } //Wait for 1 second

 

iCount++;

}

 

which waits for 1 second (which should be long enough for the future method to complete). Does anyone know why this doesn't update the original dataset?

 

Thanks

 

James 

 

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell
Your future is not run until your database transaction commits, so you can't wait for it to complete like this.

All Answers

SuperfellSuperfell
Your future is not run until your database transaction commits, so you can't wait for it to complete like this.
This was selected as the best answer
harryZharryZ

In a word, you can hardly predict how the future call executes.