开发者

Prevent Console Return

Can a VB.NET Windows Forms Application开发者_开发问答 be configured so that when run from the command-line, the command-line waits until the application exits before showing the next prompt?


You can change the command to start your application from the command line to:

start /wait YourApplication.exe

In general the command line behavior depends on the subsystem your application is using (Console/Windows). As an Application with the subsystem Windows doesn't have standard input/output streams, there is no need for the console to wait for them.

But you can change your application to be a console app and use your existing forms as usual. This link shows an example.


The code after Application.Run(new Form1()); is only run after the application has been exited. No configuration needed.

static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        string s = "test string";
        s.Trim();
    }


I think the answer is No, but a console application can show forms.


Unless the command-line is your own console app, then no.

I suppose you could create a console app that shelled out to the windows forms app... a bootstrapper of sorts. If the console app were to be launched by command-line, it might do the trick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜