不关闭控制台应用程序 [英] Console application not closing

查看:171
本文介绍了不关闭控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的深化发展是应该在的WinCE 6.0 运行控制台应用WinCE的7.0 。我使用 C# Compact Framework 2.0中不同的兼容性原因。

I'm developping a console application that supposed to run under WinCE 6.0 and WinCE 7.0. I'm using C#, Compact Framework 2.0 for different compatibility reasons.

我的应用程序由一个名为的TwinCAT (Beckhoff的)外部运行时启动。在这个应用程序,我的队友使用所谓的功能块 nt_startProcess (文档<一个href="http://infosys.beckhoff.com/english.php?content=../content/1033/tcplclibutilities/html/tcplclibutilities_nt_startprocess.htm&id"相对=nofollow>这里),其负责启动我的应用程序的需求。

My application is started by an external runtime called TwinCAT (from Beckhoff). Within this application, my teammate used a function block called nt_startProcess (documentation here) that is in charge of starting my application on demand.

我的问题 - 两种不同的行为取决于操作系统:

  1. 在从 CMD 行手动启动(没有的TwinCAT):

  1. When started manually (without TwinCAT) from a cmd line :

我的应用程序正确地在这两个系统的行为。这意味着,应用程序启动后,显示Hello World,然后返回到 CMD 行。

My application behaves properly on both systems. It means that, the applications starts, displays "Hello World" and then returns to the cmd line.

在从开始的TwinCAT:

When started from TwinCAT :

a)在的WinCE 6.0 ,我可以看到一个CMD线开通,显示Hello World的和右后关闭本身。完美的行为给我。

a) On WinCE 6.0, I can see a cmd line opening, displaying "Hello World" and shutting itself right after. Perfect behavior to me.

二)在的WinCE 7.0 ,我可以看到一个CMD线开通,显示的Hello World,但它仍然是开放的,直到永远。 这是我的问题!

b) On WinCE 7.0, I can see a cmd line opening, displaying "Hello World" but it remains open forever. This is my problem!

code片断:

using System;
using System.Collections.Generic;
using System.Text;

namespace MyBasicExample
{
  class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Hello World");
    }
  }
}

汇编信息

在Visual Studio 2008中,该项目编制的属性中:

In Visual Studio 2008, within the Project compilation's properties :

  • 。平台目标:任何CPU

其它附加注意事项:

请注意,谁正在运行的WinCE 6.0的电脑使用的是i486的处理器,而一个正在运行的WinCE 7.0是使用飞思卡尔的ARM Cortex过程。

Please note that the computer who is running WinCE 6.0 is using a i486 processor while the one running WinCE 7.0 is using a Freescale ArmCortex process.

的WinCE 6.0:

WinCE 6.0 :

的WinCE 7.0:

WinCE 7.0 :

我的尝试:

1)使用返回0; 在应用程序的结束

1) Using return 0; at the end of application.

不WinCE的7.0任何改变。

Doesn't change anything on WinCE 7.0.

2)使用 Environment.Exit(0)

不可用Compact Framework 2.0中。

Is not available in Compact Framework 2.0.

3)使用属性:的IsBackground

摘录:

// ... Same snippet as above except for the next line...
Thread.CurrentThread.IsBackground = true;
Console.WriteLine("Hello World");
// ...

4)从TwinCAT软件调用批处理文件(该调用,而不是我的EXE我的exe文件)。

4) From TwinCAT, calling a batch file (which calls my exe) instead of my exe.

不使用TwinCAT工作。我得到类型的一般分Windows错误的错误。

Doesn't work with TwinCAT. I get an error of type "General Sub-Windows error".

5)测试与契约框架3.5。

5) Tested with the Compact Framework 3.5.

相同的行为。

6)测试使用的Windows CE 7.0和其他处理器架构(英特尔奔腾III至强A型)。另外还有CX电脑(型号2020)

6) Tested with another CX computer (model 2020) using Windows CE 7.0 and another processor architecture (Intel Pentium III Xeon Model A).

相同的行为。

推荐答案

我找到解决方案从MSDN 希望这将有助于

I found solution from msdn Hope it will help

<一个href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/f0faa5e3-43ef-400d-8bca-74c7f3c4b90e/console-application-not-closing" rel="nofollow">https://social.msdn.microsoft.com/Forums/vstudio/en-US/f0faa5e3-43ef-400d-8bca-74c7f3c4b90e/console-application-not-closing

这篇关于不关闭控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆