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 

Using @future

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 

 

aebenaeben

@future methods are async methods. The method that calls the @future method is actually making a non-blocking call and will not have any idea if the @future method has failed or not. 

 

If you can elobrate on what you are trying to do, we can think of an alternate approach.

Jamz_2010Jamz_2010

Thanks for your response, I am happy that the @future call will be async and that is why I was using the wait inorder to ensure the @future had finished (the method doesn't need to know that it had finished). What I am trying to do is have a method that will make call the same method a number of times which will then select from the data set. As the select that it does may bring back more than 10,000 records, it would be good that I used an @future method to circumvent the Salesforce limitation of only 10,000 records per call. The other idea that I had for this was to select a certain set of the results, so you would get between 0 and 10,000 in the first select and between 10,000 and 20,000 in the second set. I hope it makes sense what I am trying to do.

 

James 

Jamz_2010Jamz_2010
Does anyone have any ideas what might be causing this? Is there a limitation of @future methods that they dont use live datasets?