Как создать таймер обратного счета в C#?

У меня есть код, в котором выводится текст с эффектом печатающей машинки, мне нужно чтоб юзер нажимал на кнопку где появляться таймер с обратным отсчетом, но время я заранее предустанавливаю (например 2 часа), что бы остановить таймер ему нужно ввести пароль если пароль совпадает то выходит какое-то сообщение. Часть кода которую я смог сделать сам.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GoGoBoom_v2
{
public partial class Form1 : Form
{
public Form1()
{
string text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
int countEntered = 0;
Timer t = new Timer() { Interval = 50 };
t.Tick += (s, _) =>
{
textBox1.Text = text.Substring(0, ++countEntered);

if(countEntered >= text.Length) t.Enabled = false;
};

t.Start();
InitializeComponent();
}




private void buttonYes_Click(object sender, EventArgs e)
{

}
}
}

Помогите допилить код.
  • Вопрос задан
  • 363 просмотра
Пригласить эксперта
Ответы на вопрос 1
@Tesla2018
Добавить textbox и проверять введенный текст, если он соответствует паролю то выключить таймер или сделать еще какое-нибудь действие.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы