摘要: 终止异步方法的实现主要依靠 CancellationToken 类 using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; namespace ConsoleApp21 { 阅读全文
posted @ 2022-09-05 00:19 元数据 阅读(1772) 评论(0) 推荐(0)
摘要: 1、可以把资源词典看作是一个容器,这个容器可以存放各种各样的控件样式,其他WPF窗体只需要引用这个容器的样式就行了,从而避免大量的重复代码。 2、在visual studio中添加了资源词典,并且在资源词典中写好了控件样式,WPF在窗体引用前还需要在App.xmal中添加引用,具体引用代码如下: 1 阅读全文
posted @ 2022-03-20 13:33 元数据 阅读(232) 评论(0) 推荐(0)
摘要: 有时需要通过C#一次性插入或更新大量数据到SQL Server中,使用insert into/update这种方式就会变得异常缓慢,这个时候可以使用到表值参数来一次性插入或更新大量数据。需要注意,UpdateSale方法table参数的结构需要和表自定义类型结构、数据库表结构一样,比如下面的Type 阅读全文
posted @ 2021-12-19 17:06 元数据 阅读(1802) 评论(0) 推荐(0)
摘要: 当winForm窗体FormBorderStyle属性改为None时,winForm窗体就会变成无边框。但此时会出现鼠标无法拖动winForm窗体现象,这个时候添加以下代码和事件就能恢复正常,具体代码如下: [DllImport("user32.dll")] public static extern 阅读全文
posted @ 2021-12-19 16:23 元数据 阅读(192) 评论(0) 推荐(0)
摘要: 克隆仓库代码 git clone https://xxxxxxxxxxxxxxxxx 本地代码与仓库项目关联 git remote add upstream https://xxxxxxxxxxxxxxxxx 拉取仓库代码 git fetch upstream 提交修改代码 git commit - 阅读全文
posted @ 2021-11-25 14:38 元数据 阅读(34) 评论(0) 推荐(0)
摘要: 1 select top (10) LogId,LoginId,SPName,ServerName,LoginTime,ExitTime from LoginLogs 2 where LogId not in (select top(10 *(3-1)) LogId from LoginLogs) 阅读全文
posted @ 2021-09-07 11:30 元数据 阅读(50) 评论(0) 推荐(0)
摘要: 第一种实现方法: 首先需要引用名称控件:using System.Diagnostics; 也可以把计数变量放在配置文件当中,方便以后的修改,下面是具体实现代码: 1 Process[] processes = Process.GetProcesses(); //获得本机所有应用进程 2 int c 阅读全文
posted @ 2021-09-06 18:59 元数据 阅读(1196) 评论(0) 推荐(0)
摘要: 使用事务能有效的避免更新数据时,旧数据没更新,新数据已经添加的情况。当然也可以通过SQL本身运行事务。 1 public static bool UpdateByTran(List<string>sqlList) 2 { 3 SqlConnection conn = new SqlConnectio 阅读全文
posted @ 2021-09-01 22:57 元数据 阅读(737) 评论(0) 推荐(0)
摘要: 1、获取本机计算机名字 引用名称空间 using System.Net 获取计算机名字 string str = Dns.GetHostName() 2、获取本机IP地址 获取IP地址同样需要 using System.Net名称空间 string addressIp = string.Empty; 阅读全文
posted @ 2021-08-12 09:30 元数据 阅读(1866) 评论(0) 推荐(0)