-
-
Save sabadoc/224c6410ede25928d4900de030a78e9e to your computer and use it in GitHub Desktop.
apex wait method sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reference: http://www.xgeek.net/salesforce/a-way-to-make-thread-sleep-in-apex/ | |
public class ApexUtil { | |
/********************************************************** | |
* Helper Method: wait | |
* @param Integer millisec : time for wait (millisecond) | |
*********************************************************/ | |
public static void wait(Integer millisec) { | |
if(millisec == null || millisec < 0) { | |
millisec = 0; | |
} | |
Long startTime = DateTime.now().getTime(); | |
Long finishTime = DateTime.now().getTime(); | |
while ((finishTime - startTime) < millisec) { | |
//sleep for parameter x millisecs | |
finishTime = DateTime.now().getTime(); | |
} | |
// System.debug('>>> Done from ' + startTime + ' to ' + finishTime); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment