时间循环c#while/if

wha*_*ver 0 c# loops if-statement while-loop

我需要C#循环的帮助.循环需要做什么:

xt = 50

现在程序需要等待时间(x = 50),每秒递减一次.如果实际时间为0,程序需要发送我的请求并设置xt = 50.所以循环可以重新开始,所有这一段代码都应检查每50秒向服务器发送一个请求.

我的实际代码:

while (xt != 0)
{
    xt--;
    Thread.Sleep(1000);
    Console.WriteLine ("bla:"+ xt);
}

if (xt == 0)
{
    Console.WriteLine("Ich sende!");
    //post.SendPost(randomengine.decodeb64(URL2),"Alive");//richtige Daten eintragen! Idiot!
    xt = 50;
}
Run Code Online (Sandbox Code Playgroud)

Shi*_* cv 6

 DispatcherTimer tmr = new DispatcherTimer();
        tmr.Interval = TimeSpan.FromSeconds(50);
        tmr.Start();
        tmr.Tick += (sndr, ex) =>
            {
                //send request 
            };
Run Code Online (Sandbox Code Playgroud)

我希望这有帮助,这个Tick事件将在每50秒后触发一次