Dear All, Please need your support i dovleped one application and there while loop which keep runining and condition there is spcific time like if time reach 13:00 then go to next code its working fine no issue found but only one issue while loop keep runinig and chekcing time for this system process using like 25% and more how can i reduce this and or is there another way to run application with spcific time without consuming system high processing. please advice below code for your refrence.
while (true)
{
if (System.DateTime.Now.ToString("HH:mm") == "13:15")
{
int i;
for (i = 0; i < 35; i++)
{
}
}
else
{ }
}
Amit MohantyPosted Jul 20, 2023, 2:30 PM
You can use System.Timers.Timer or System.Threading.Timer to run a specific code block at a specific time without busy-waiting. Here's an example using System.Timers.Timer:
Deepak RawatPosted Jul 21, 2023, 5:51 AM
Timerclass in C#. can perform this task:Muhammad Imran AnsariPosted Jul 20, 2023, 7:57 PM
You can achive this through timer class. Here is the code example: