停止焦点改变事件在一秒钟内被多次处理

时间:2018-05-20 12:08:17

标签: c# winforms

我在后台MTA线程上有一个焦点更改事件处理程序(uia),用于更新当前活动窗口的元素列表,在更改活动窗口时,该窗口会在一秒内多次触发。我试图让它去一次,然后在处理任何其他事件之前等待一秒钟。问题是计时器启动但从未触发过?我想有更好的方法吗?代码示例很棒。

server {
listen 80;
server_name domain1.com;
return 301 https://$host$request_uri;
}



server {

    listen 443 ssl;
    server_name domain1.com;
    root /app/dist;

    index index.html;

    ssl_certificate /etc/nginx/ssl/d1/certificate.crt;
    ssl_certificate_key /etc/nginx/ssl/d1/private.key;

    location / {

        try_files $uri $uri/ /index.html;

    }

}

server {
listen 80;
server_name domain2.com;
return 301 https://$host$request_uri;
}



server {

    listen 443 ssl;
    server_name domain2.com;
    root /app/dist;

    index index.html;

    ssl_certificate /etc/nginx/ssl/d2/certificate.crt;
    ssl_certificate_key /etc/nginx/ssl/d2/private.key;

    location / {

        try_files $uri $uri/ /index.html;

    }

}

1 个答案:

答案 0 :(得分:0)

尝试:每次事件触发,重置计时器。

public partial class Form1 : Form
{

    Timer t = new Timer();

    public Form1()
    {
        InitializeComponent();
        t.Interval = 1000;
        t.Tick += ((ss, ee) => {
            t.Enabled = false;
            focusChangedCounter = 0;
            focusChangedBufferTimer.Stop();
            focusChangedBufferTimer = null;
        });
    }

    private void HandleFocusChangedEvent(object sender, EventArgs e)
    {
        t.Enabled = false;
        t.Enabled = true;
    }
}