我想要populate属性 [英] I want populate Property
本文介绍了我想要populate属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是编程新手,我想在每分钟后填充属性。
I am new in programming, i want to populate property after every minute.
namespace Testing
{
public partial class Test : Window
{
private static Test _instance;
public static Test GetInstance()
{
return _instance;
}
public DateTime LastHitTime { get; set; }
System.Windows.Threading.DispatcherTimer timer1 = new System.Windows.Threading.DispatcherTimer();
public Test()
{
_instance = this;
InitializeComponent();
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Interval = new TimeSpan(0, 0, 1);
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
LblOne.Content = LastHitTime.ToString("HH:mm:ss");
}
}
}
最后一次获得的价值来自
last hit value get from
namespace Testing
{
public class Hits : Log
{
public void onHit(String text)
{
Test ui = Test.GetInstance();
Action action = () =>
{
ui.LastHitTime = System.DateTime.Now;
};
Log.DebugFormat("onIncoming: {0}", text);
}
}
}
i希望在Test类中获取ui.lasthittime,plz帮助我。
i want to get ui.lasthittime in Test class, plz help me.
推荐答案
namespace Testing{
public partial class Test : Window{
private static Test _instance;
public static Test GetInstance(){
return _instance;
}
public DateTime LastHitTime { get; set; }
System.Windows.Threading.DispatcherTimer timer1 = new System.Windows.Threading.DispatcherTimer();
public Test(){
_instance = this;
InitializeComponent();
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Interval = new TimeSpan(0, 0, 1);
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e){
LblOne.Content = LastHitTime.ToString("HH:mm:ss");
}
}
}
namespace Testing{
public class Hits : Log{
public void onHit(String text){
Test ui = Test.GetInstance();
ui.LastHitTime = System.DateTime.Now;
Log.DebugFormat("onIncoming: {0}", text);
}
}
}
这篇关于我想要populate属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文