Skip to content

Console.ReadKey()引发的问题 #234

@agentwx

Description

@agentwx

在使用过程中发现, 如果是C#控制台程序,里面本身用到了timer做定时任务所以在main函数里使用了Console.ReadKey()来阻塞。
然后用winsw注册成系统服务后,点击开启服务,会报错
System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
at System.Console.ReadKey(Boolean intercept)
at ServiceActiveConsole.Program.Main(String[] args)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions