所以我想每秒查看当前select min (case catid when 1 then name end) as catname1
,min (case catid when 2 then name end) as catname2
from (select row_number () over (partition by catid order by name) as rn
,catid
,name
from deemucty.sample12
) t
group by rn
order by rn
;
,如果time
加注seconds == 0
并显示当前时间:
event
用法:
using System.Timers;
public delegate void TimeHandler(object sender, TimeEventArgs e);
public class Clock
{
private Timer timer;
public event TimeHandler CurrentTime;
public Clock()
{
timer = new Timer();
timer.Elapsed += timer_Elapsed;
timer.Interval = 1000;
}
public void Start()
{
timer.Enabled = true;
timer.Start();
}
private void timer_Elapsed(object sender, ElapsedEventArgs e)
{
DateTime time = DateTime.Now;
int sec = time.Second;
if (sec == 0)
if (CurrentTime != null)
CurrentTime(this, new TimeEventArgs(time));
}
}
public class TimeEventArgs
{
public readonly DateTime Time;
public TimeEventArgs(DateTime time)
{
Time = time;
}
}
但似乎计时器没有启动。
答案 0 :(得分:0)
您的timer_Elapsed
不匹配currentTime
和CurrentTime
。如果检查委托,则应使用处理程序的大写名称。
您可以通过在其中设置断点或在开头直接放置日志消息来确保调用Elapsed
处理程序。
最后,Clock_CurrentTime
每分钟只会调用一次。