问题在于,我真的不希望控制台窗口出现,但解决方案应该是运行的。 我的意思是,我想让应用程序在后台运行,而不会出现任何窗口。
我该怎么做?
问题在于,我真的不希望控制台窗口出现,但解决方案应该是运行的。 我的意思是,我想让应用程序在后台运行,而不会出现任何窗口。
我该怎么做?
Console.ReadLine
。如果没有控制台窗口,它是毫无意义的。 - Dirk Vollmar你可以使用 new ManualResetEvent(false).WaitOne()
代替 Console.Readline/key
,这在我的实践中非常有效。
你可以使用 user32.dll 来实现这一点,而无需使用 vscode。
class start
{
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
static void Main()
{
IntPtr h = Process.GetCurrentProcess().MainWindowHandle;
ShowWindow(h, 0);
// Do the rest
using System.Runtime.InteropServices;
using System.Diagnostics;
请注意,我仍然是C#新手,不是完美的,所以欢迎评论和修正!
csc.exe /target:winexe *.cs