문제

I need help with DateTime.
I want my application to check if DateTime end is up and gives me a messagebox.
How do I write that?
Code:

private void listjob()
{
    DispatcherTimer dispatcherTimer = new DispatcherTimer();
    dispatcherTimer.Tick += new EventHandler(listjob3_Tick);
    dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
    dispatcherTimer.Start();
}
private void listjob3_Tick(object sender, EventArgs e)
{
    if (listbox3job())
    {
        DateTime? start = DateTimePicker1.Value;
        DateTime? end = DateTimePicker2.Value;
        DateTime now = DateTime.Now;
        if (?) // here is what I want it to check if end time is started
        {
           Xceed.Wpf.Toolkit.MessageBox.Show("End Time started");
           DispatcherTimer timer = (DispatcherTimer)sender;
           timer.Stop();
           timer = null;
        }
    }
}
도움이 되었습니까?

해결책

Unless I'm grossly misunderstanding what you want:

if (now >= end)

or in other words, if the current time is greater than or equal to the end time. If you just wanted to know if the current time is past the end time then:

if (now > end)

다른 팁

if(end<= now)

It's just like that. If you have some issue with the type, use ToShortDateString() or other properties

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top