![]() Timer.Tick += new EventHandler(TimerTick) Private bool _mustStop => (_max.TotalMilliseconds - _stpWatch.ElapsedMilliseconds) string TimeLeftMsStr => void TimerTick(object sender, EventArgs e) Public TimeSpan TimeLeft => (_max.TotalMilliseconds - _stpWatch.ElapsedMilliseconds) > 0 ? TimeSpan.FromMilliseconds(_max.TotalMilliseconds - _stpWatch.ElapsedMilliseconds) : TimeSpan.FromMilliseconds(0) Private TimeSpan _max = TimeSpan.FromMilliseconds(30000) Public Stopwatch _stpWatch = new Stopwatch() Public class CountDownTimer : IDisposable Private void Form1_FormClosing(object sender, FormClosingEventArgs e) Private void button3_Click(object sender, EventArgs e) Private void button2_Click(object sender, EventArgs e) Private void button1_Click(object sender, EventArgs e) Timer.StepMs = 1 // for nice milliseconds time switchĬonsole.WriteLine() TimeSpan passedtime = DateTime.Now - closedtime TimeSpan time1=TimeSpan.ParseExact(lefttime, CultureInfo.CurrentCulture) ĭateTime closedtime = Private void Form1_Load(object sender, EventArgs e) =DateTime.Now įourth, I used Form1_Load event to read the information. private void Form1_FormClosing(object sender, FormClosingEventArgs e) Third, I used FormClosing event to save some information to the settings. Second, I add the following settings in the winform. You could check if it works for you.įirst, I make a countdown Timer from the answer. Welcome to Microsoft Q&A, Based on your description, you want to make a countdown timer and hope that it will contine when the form is closed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |