linq

C# windows服务定时执行

北城以北 提交于 2020-09-30 12:21:09
十年河东,十年河西,莫欺少年穷 学无止境,精益求精 接着上一篇: C# 创建windows服务 并通过winform 程序控制服务的 安装 启动 停止 卸载 本节来看看如何实现定时执行windows服务,其实也没什么好说的,时间紧急,主要就是代码,如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.IO; using System.Linq; using System.ServiceProcess; using System.Text; using System.Threading.Tasks; namespace WindowsServices { public partial class MyService : ServiceBase { System.Timers.Timer timer1; // 计时器 string filePath = @" D:\MyServiceLog.txt " ; public MyService() { InitializeComponent(); } protected override void OnStart(

BitArray虽好,但请不要滥用,又一次线上内存暴增排查

安稳与你 提交于 2020-09-29 11:05:29
一:背景 1. 讲故事 前天写了一篇大内存排查在园子里挺火,这是做自媒体最开心的事拉,干脆再来一篇满足大家胃口,上个月我写了一篇博客提到过使用bitmap对原来的List<CustomerID>进行高强度压缩,将原来的List内存压缩了将近106倍,但是bitmap不是一味的好,你必须在正确的场景中使用,而不是闭着眼睛滥用,bitmap在C#中对应的集合是BitArray。 好像剧透了,结果就是BitArray的滥用导致内存小10G的涨跌,不过这种东西重点还是看解决思路,写给以后的自己,可不能让这难得的实践经验蒸发啦~~~ 二:解决思路 1. 一看托管堆 看托管堆虽然是一个好主意,但也不是每次都凑效,毕竟造成内存暴涨暴跌的原因各种各样,就像人感冒有风寒,风热和病毒性,对吧,还是使用老命令: !dumpheap -stat -min 102400 ,在托管堆上找大于100M的对象。 0:030> !dumpheap -stat -min 102400 Statistics: MT Count TotalSize Class Name 00007ffe094ec988 1 1438413 System.Byte[] 00007ffdab934c48 1 1810368 System.Collections.Generic.Dictionary`2+Entry[[System.Int32

C# windows服务定时执行

强颜欢笑 提交于 2020-09-29 00:58:07
十年河东,十年河西,莫欺少年穷 学无止境,精益求精 接着上一篇: C# 创建windows服务 并通过winform 程序控制服务的 安装 启动 停止 卸载 本节来看看如何实现定时执行windows服务,其实也没什么好说的,时间紧急,主要就是代码,如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.IO; using System.Linq; using System.ServiceProcess; using System.Text; using System.Threading.Tasks; namespace WindowsServices { public partial class MyService : ServiceBase { System.Timers.Timer timer1; // 计时器 string filePath = @" D:\MyServiceLog.txt " ; public MyService() { InitializeComponent(); } protected override void OnStart(