111,076
社区成员




private void Timer_Tick(object sender, EventArgs e)
{
DateTime currnetDateTime = DateTime.Now;
TimeSpan timeSpan = currnetDateTime - startDateTime;//startDateTime是一个全局变量,已定义
string content = timeSpan.Hours.ToString("D2") + ":" + timeSpan.Minutes.ToString("D2") + ":" +
timeSpan.Seconds.ToString("D2") + "." + (timeSpan.Milliseconds / 1000.0d);
TimeLabel.Content = content;
}
public static class ExtensionMethods
{
private static Action EmptyDelegate = delegate ()
{ };
public static void Refresh(this UIElement uiElement)
{
uiElement.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
}
}
private void Timer_Tick(object sender, EventArgs e)
{
DateTime currnetDateTime = DateTime.Now;
TimeSpan timeSpan = currnetDateTime - startDateTime;//startDateTime是一个全局变量,已定义
string content = timeSpan.Hours.ToString("D2") + ":" + timeSpan.Minutes.ToString("D2") + ":" +
timeSpan.Seconds.ToString("D2") + "." + (timeSpan.Milliseconds / 1000.0d);
TimeLabel.Content = content;
TimeLabel.Refresh();
}