web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to exit a loop after specific time.

(0) ShareShare
ReportReport
Posted on by 225

Hello,

I want to exit a loop after specific time. Can anyone let me know how i can achieve this.

I want to do something like below:

do

{

// Third party call to check for specific condition

}

While(condition);

Info("It is taking longer than expected. Please try again");

I have the same question (0)
  • Suggested answer
    Anton Venter Profile Picture
    20,297 Super User 2025 Season 2 on at
    RE: How to exit a loop after specific time.

    if condition evaluates to false, it will stop. Setting condition to false will stop the loop.

  • Pratik Rami Profile Picture
    225 on at
    RE: How to exit a loop after specific time.

    Yes.. but i also want to exit the loop based on specific time..there are 2 cases.

    1) condition becomes false or

    2) 30 seconds

    After 30 seconds if condition is still true then also i want to exit.

  • Suggested answer
    Anton Venter Profile Picture
    20,297 Super User 2025 Season 2 on at
    RE: How to exit a loop after specific time.

    You could use the System.Diagnostics.Stopwatch class to measure the elapsed time and set the condition to stop. I have not tested this so it might not work but I expect it should.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,122

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 918 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 646 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans