随笔分类 -  C#

摘要:窗体代码 思路获取主窗体的位置坐标,根据主窗体的位置坐标和长宽尺寸计算子窗体的实际位置,并赋值给子窗体的Top和Left属性。 public partial class PromptDialogBox : Window { /// <summary> /// 关闭计时器 /// </summary> 阅读全文
posted @ 2024-12-27 09:56 follow_discoverer 阅读(29) 评论(0) 推荐(0) 编辑
摘要:客户端代码: 1 byte[] ReadBytes = new byte[1024]; 2 private void ConnectServer_Camera(string ip, int port) 3 { 5 tcpclient= new TcpClient(); 6 tcpclient.Beg 阅读全文
posted @ 2024-03-12 20:59 follow_discoverer 阅读(23) 评论(0) 推荐(0) 编辑
摘要:在应用程序中有时需要一个http接口来与第三方通讯。 下面是个简单的代码示例: 1 public async void StartHttpListener(string url) 2 { 3 HttpListener httpListener=new HttpListener(); 4 httpLi 阅读全文
posted @ 2024-02-24 14:37 follow_discoverer 阅读(31) 评论(0) 推荐(0) 编辑
摘要:主要区别是Task.Factory.StartNew可以设置该线程是长时间运行线程,防止线程池等待回收这个线程。 阅读全文
posted @ 2024-01-05 15:15 follow_discoverer 阅读(47) 评论(0) 推荐(0) 编辑
摘要:在xaml文件中引入命名空间:System.Windows.Forms xmln:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" 使用方式: <WindowsFormsHost> <wf:PictureBox 阅读全文
posted @ 2023-12-05 11:49 follow_discoverer 阅读(265) 评论(0) 推荐(0) 编辑
摘要:在.net 5.0的wpf项目中添加了System.Windows.Forms.dll引用之后窗体自带的初始化方法直接报错。 解决办法:在项目文件.csproj里的<PropertyGroup>标签子节点添加 <UseWindowsForms>true</UseWindowsForms> 阅读全文
posted @ 2023-08-09 09:16 follow_discoverer 阅读(256) 评论(0) 推荐(0) 编辑
摘要:一、以App扩展方法检查进程名和进程ID的方式 1 Public static T SetSingleProcess(this T app)Where T:Application 2 { 3 var process=Process.GetProcesses().Where(p=>p.ProcessN 阅读全文
posted @ 2023-07-11 20:40 follow_discoverer 阅读(162) 评论(0) 推荐(0) 编辑
摘要:服务端代码 TcpListener tcpListener=new TcpListener(IPAddress.Parse("192.168.1.1"),9000); tcpListener.Start();//启动服务 While(true) { TcpClient tcpClient=tcpLi 阅读全文
posted @ 2023-06-29 13:43 follow_discoverer 阅读(105) 评论(0) 推荐(0) 编辑
摘要:获取网卡IP地址代码如下: var address=System.Net.Dns.GetHostAddresses(Dns.GetHostName()).Where(m=>m.IsIPv6LinkLocal==false).Select(m=>m.ToString()).ToList(); retu 阅读全文
posted @ 2023-06-13 16:14 follow_discoverer 阅读(72) 评论(0) 推荐(0) 编辑
摘要:PerformanceCounter performanceCounter = new PerformanceCounter("Process", "Working Set - Private", Process.GetCurrentProcess().ProcessName);var result 阅读全文
posted @ 2023-06-13 16:05 follow_discoverer 阅读(13) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示