N
N
NeoLight22020-06-20 16:27:10
C++ / C#
NeoLight2, 2020-06-20 16:27:10

How to loop once on the end of a timer in C#?

How to make the timer run only 1 time and after it ends, the loop is executed
(only 1 time)?

The code:

NetworkChat.sendAlert("Airdrop will fall to the Summerside Peninsule after 5 min!");
airdrop = new System.Timers.Timer(300000);
airdrop.Elapsed += AirdropElapsed;
while (AirdropElapsed.istrue == true)
{
  NetworkChat.sendAlert("Airdop was fallen to Summerside Peninsula!");
  Vector3 summerside = new Vector3(790, 24, -450);
           int[] array2 = array;
          foreach (int num in array2)
          {
            SpawnItems.spawnItem(num, 1, summerside);
          }
          NetworkChat.sendAlert(messageAfterDrop);
}
airdrop.Enabled = false;

A photo:
5eee0ea89cff9985549892.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-06-20
@firedragon

Create a thread that will call the function 1 time, then sleep for an interval and call the function again. And no timer needed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question