[英]Return Value by closing MainWindow
I have a WPF Application. 我有一个WPF应用程序。 It´s for testing a process.
用于测试流程。 I start this over a console.
我从控制台开始。 When the process ends, the MainWindow will be closed with Window.Close().
当过程结束时,MainWindow将通过Window.Close()关闭。 Now I try to return a integer value when my program closes.
现在,我尝试在程序关闭时返回一个整数值。 It is possible to see this value in my console?
可以在控制台中看到此值吗?
For example in Java has the method System.Exit(1). 例如,在Java中,方法System.Exit(1)。 Then I can see the return value on my console.
然后,我可以在控制台上看到返回值。 But is it possible in WPF Applications?
但是在WPF应用程序中可能吗?
Maybe this is also the solution bottle and somebody has a better idea. 也许这也是解决方案,但有人有更好的主意。
You call: 您致电:
Application.Current.Shutdown(1);
See this question for more info: How to exit a WPF app programmatically? 有关更多信息,请参见此问题: 如何以编程方式退出WPF应用程序?
I believe you can call Environment.Exit(code)
我相信你可以打电话给
Environment.Exit(code)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.