2020年6月16日

BackGroundWork

摘要: BackgroundWorker类允许您在单独的线程上执行某个可能导致用户界面(UI)停止响应的耗时操作(比如文件下载数据库事务等),并且想要一个响应式的UI来反应当前耗时操作的进度。DoWork 用于承载异步操作。当调用BackgroundWorker.RunWorkerAsync()时触发。 需 阅读全文

posted @ 2020-06-16 21:08 fanu 阅读(274) 评论(0) 推荐(0)

单例启动程序

摘要: string FilePath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, AppDomain.CurrentDomain.SetupInformation.ApplicationName); As 阅读全文

posted @ 2020-06-16 14:45 fanu 阅读(149) 评论(0) 推荐(0)

2020年5月11日

证书验证和添加证书

摘要: 问题:AuthenticateAsClient验证时间12秒 原因:离线电脑没有安装对应的证书,X509Chain.Build()会上网查找受信任的证书。(网上问题资料 https://blogs.msdn.microsoft.com/alejacma/2011/09/27/big-delay-wh 阅读全文

posted @ 2020-05-11 16:43 fanu 阅读(416) 评论(0) 推荐(0)

2020年4月22日

使用.Net Remoting/RealProxy 实现动态代理

摘要: public class ClassRealProxy<T>:RealProxy { private T tTarget; public ClassRealProxy(T target):base(typeof(T)) { this.tTarget = target; } public overri 阅读全文

posted @ 2020-04-22 00:16 fanu 阅读(388) 评论(0) 推荐(0)

2020年3月24日

清理图标缓存

摘要: rem 关闭Windows外壳程序explorertaskkill /f /im explorer.exerem 清理系统图标缓存数据库attrib -h -s -r "%userprofile%\AppData\Local\IconCache.db"del /f "%userprofile%\Ap 阅读全文

posted @ 2020-03-24 15:15 fanu 阅读(287) 评论(0) 推荐(0)

2020年3月16日

C#序列化与反序列化

摘要: public static void Serialization<T>(string path, T type) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); using (Stream stream = new File 阅读全文

posted @ 2020-03-16 15:22 fanu 阅读(111) 评论(0) 推荐(1)

2020年3月13日

C#更新exe文件图标

摘要: private static void ReplaceExeIco(string exepath, string icopath) { try { FileStream fileStream = new FileStream(icopath, FileMode.Open, FileAccess.Re 阅读全文

posted @ 2020-03-13 16:44 fanu 阅读(830) 评论(1) 推荐(1)

2020年3月9日

Socket快速应答

摘要: int SIO_TCP_SET_ACK_FREQUENCY = unchecked((int)0x98000017);var outputArray = new byte[128];var bytesInOutputArray = this._listener.Server.IOControl(SI 阅读全文

posted @ 2020-03-09 17:42 fanu 阅读(327) 评论(0) 推荐(0)

TCPClient关闭连接问题

摘要: TCPClient主动关闭连接后会残留TIME_WAIT状态,影响到下一次使用同一端口连接时会报“通常每个套接字地址(协议/网络地址/端口)只允许使用一次”异常,TIME_WAIT状态保持30S左右. 解决方法: 1、服务端关闭相应的TCP连接。 2、TCP使用长连接机制。 阅读全文

posted @ 2020-03-09 17:40 fanu 阅读(1005) 评论(0) 推荐(0)

检测端口可用性

摘要: private int CheckPortUsing() { int port = 20000; bool isgoto = false; begin: Process process = new Process(); process.StartInfo.FileName = "cmd.exe"; 阅读全文

posted @ 2020-03-09 15:25 fanu 阅读(274) 评论(0) 推荐(0)

导航