一.异常提示 不支持一个 STA 线程上针对多个句柄的 WaitAll. 出错界面如下图: 二.解决方法 先直接上解决方案吧.其实解决方法很简单如下面的代码直接把main函数的[STAThread]属性注释掉就行了.或者把[STAThread]替换成[MTAThread] using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Win…
[csharp] view plaincopy using System; using System.Collections.Generic; using System.Windows.Forms; namespace WindowsApplication1 { static class Program { /// <summary> /// 应用程序的主入口点. /// </summary> [MTAThread] //不支持一个 STA 线程上针对多个句柄的 WaitAll.解…
delegate--委托 (可以把委托看成用来执行方法的一个东西) eg: namespace delegateTest{ delegate double MathsOp(double x); class Program { public class MyDelegate { public static double MultiplyBy2(double x) { return x * 2; } } [STAThread]//[STAThread] attribute指示应用程序的 COM 线程…
前言 在开发应用程序时,通常只让程序运行一个实例.所以,就要判断程序是否已经运行. 下面是我自己在项目中使用到,封装好的帮助类.有 普通的 C# 应用程序 和 Windows CE 和 Windows Mobile 应用程序使用的方法. 主要是通过 System.Threading.Mutex 类 和 Win32 API 来实现,下面就是各自的代码,调用示例在最后面. 普通 C# 应用程序 主要是 Windows 窗体应用程序和控制台程序. 1. 使用 System.Threading.Mute…
捕获控制台(console)关闭事件: 1.Ctrl+C信号: 2.Ctrl+Break信号: 3.用户系统关闭Console时: 4.用户退出系统时: 5.系统将要关闭时: using System; using System.Runtime.InteropServices; using System.Threading; using System.Diagnostics; namespace ConsoleApplication2 { public delegate bool Console…
https://www.codeproject.com/articles/31236/how-to-update-assembly-version-number-automaticall Examples AssemblyInfoUtil.exe -set:3.1.7.53 "C:\Program Files\MyProject1\AssemblyInfo.cs" Set the version string to "3.1.7.53". AssemblyInfoU…
1: //在写一些服务型的软件的时候,你可能不希望一个操作系统里有两个副本在运行,这样也许会扰乱你的操作.这时,你就需要限制程序的副本.下面的这个方法,很简单的就可以实现上述功能. using System; using System.Collections.Generic; using System.Windows.Forms; using System.Diagnostics; namespace TestProcessCount { static class Program { /// <…