首页 > 编程语言 >c# 设置一段时间后执行

c# 设置一段时间后执行

时间:2022-11-23 14:24:43浏览次数:63  
标签:控件 c# 一段时间 System timer Timers 设置

wpf控件的MouseEnter事件中设置5秒后隐藏控件

System.Timers.Timer timer = new System.Timers.Timer(5 * 1000);//5秒
timer.Elapsed += new System.Timers.ElapsedEventHandler(delegate (object obj, System.Timers.ElapsedEventArgs el)
{
    this.Dispatcher.Invoke((Action)delegate ()
    {
        timer.Enabled = false;
        //实现
    });
});
timer.AutoReset = false;
timer.Enabled = true;

原文:c#设置定时器,在一定时间之后自动执行事件

调用线程无法访问此对象,因为另一个线程拥有该对象。

 

标签:控件,c#,一段时间,System,timer,Timers,设置
From: https://www.cnblogs.com/fangxinliu/p/16918106.html

相关文章

  • mysql使用sys和performance_schema查看慢查询
    select schema_name, format_pico_time(total_latency)total_latency, exec_count, format_pico_time(total_latency/exec_count)latency_per_call, query_sample_......
  • C# List分页
    List.Skip((pagecount-1)*pagesize).Take(pagesize)假设你每页10条数据当前是第3页跳到第4页则:List.Skip((4-1)*10).Take(10) intnumb=100;intsize=(int)Math.C......
  • 周六900C++班级-2022-11-19 01背包
    背包问题关系图  问题描述若有N件物品和一个最多能装重量为W的背包,一个物品只有两个属性:重量和价值。第i件物品的重量是weight[i],得到的价值是value[i]。假......
  • FR11 webservice程序数据集
    packagecom.fr.data;importcn.hutool.core.lang.Console;importcn.hutool.http.webservice.SoapClient;importcn.hutool.json.JSONArray;importcn.hutool.json.......
  • Sysbench安装最新版本(Debian/Ubuntu/RHEL/CentOS/Fedora)
    重要说明:sysbench在Git上的各个版本二进制包下载路径:https://github.com/akopytov/sysbench/releases如下的2种安装方式,任选一种即可第一种:Quickinstallinstructions:......
  • OpenCv4.6.0交叉编译ARM(aarch64)平台库
    1.下载交叉编译工具:gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu2.opencv官网下载opencv4.6.0源码,opencv官网下载opencv4-contrib-4.6.03.解压缩,并在源码包中新......
  • mac navicat premium 无限使用
    macm2navicatpremium下载plistediter下载后是.app文件可以直接使用移动到程序坞中方便面后期使用打开plistopen~/Library/Preferences/com.navicat.Navica......
  • Vulnhub之Hacksudo ProximaCentaur靶机解题过程
    HacksudoProximaCentaur识别目标主机IP地址─(kali㉿kali)-[~/Vulnhub/Hacksudo_ProximaCentaur]└─$sudonetdiscover-ieth1Currentlyscanning:172.16.2.0/16......
  • 社区活动 | Apache Flink Meetup·深圳站,锁定 Flink 最佳实践
    Apache Flink Meetup 2020·深圳站正!式!上!线!如何基于Flink+Iceberg构建企业级数据湖?HudionFlink有哪些生产环境应用实践?基于Flink搭建的监控体系如何更立体?......
  • Dell R740 idrac配置
    ......