Windows窗体应用程序不是“结束”当您关闭窗体窗口时 [英] Windows Forms apps not "ending" when you close the form window

查看:69
本文介绍了Windows窗体应用程序不是“结束”当您关闭窗体窗口时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我关闭表单窗口时,我一直遇到C ++ Windows窗体应用程序的问题而不是结束

。我已经在这个地方搜索了这个问题所有

,并且大多数搜索都让我相信这与未发布的表单组件事件或事件处理程序有关。


我对.net和windows表单比较新,从某种意义上来说,虽然我已经使用它们超过2年了,它已经是零星的b / b
。我使用计算机 - 机器接口相当多,所以我是b $ b主要做ANSI C ++ / STL,所以东西可以在

实现者选择的任何操作系统上运行,并且输入通常由外部

组件处理,该组件与此代码相关联。最近,越来越多的

实例在需要适当的用户界面的地方上升了,并且

Windows Forms在提供令人难以置信的快速的方面非常出色

开发过程甚至是多表格,解析输入,

验证要求的应用程序。也就是说,直到我决定在应用程序内部获得一些

信息处理代码...


到目前为止,我去过创建输入表单,然后

(在提交信息后)将此信息发送到其他地方

进行处理。有时这需要一些额外的处理,而另一个程序,有时它只是直接连接到连接到外部元素的

接口,通常是某种

嵌入式设备可以缓存数据,同时将数据提供给任何

机制正在使用它。


现在,我已经我知道客户将使用仅限Windows的情况,并将电脑

直接连接到设备,即缓冲。所以我想我会尝试为每个人简化一些事情,并将所有内容放在一个

C ++。net app中。显然,这有一些我不知道的固有问题

。以前,我创建的Forms应用程序只是获取了数据,进行了非常温和的解析,并输出了一些XML文件,以便由另一个

程序获取。现在,数据需要进行数学操作,将表单发送回形式显示为图形,然后才发送到输出元素的
。我甚至没有达到输出阶段,并且已经在大部分时间运行程序的时间点已经是b $ b,用它来工作

咬住它并不会结束这个过程。在调试模式下,

表格就消失了,但是调试继续进行,因为进程

仍处于活动状态。


为了澄清,我的背景是以中心为中心。说明符号

排队,得到处理,然后阙继续前进。这就是我的理念是如何工作的,因为我主要使用单线程C ++ / STL来实现更大规模的系统和C / asm的嵌入式工作。所有与指针相关的

东西都放在容器中,数组也是如此。如果它已嵌入,请使用

宏来确保您不要将悬挂的东西留下。对于Windows程序员来说,这可能是b $ b,但实际上,即使使用了最新的PicMicro dsPics,你也不会经常使用。因此,整个

概念,你有一个人跑,在空中投球,

继续运行,并在球落下时接球以便看到什么

坚持下去,对我来说是个新鲜事。而且,如果我有这个权利,这个

并不是真正的线程,或者是它?是否与托管的

堆有关?


我还应该提到应用程序并不是真的需要当表格关闭时,用户要做任何事情才能保持开放状态。

有时我会运行它,并且几乎立即关闭它,它仍然是
/>
仍然有效。我已经缩小了控件,所以现在只有一个按钮,一个轨迹栏和一个放置图表的面板。

它是'调用数学过程所需的最少元素是

调用然后发回。


所以基本上,关于这个主题的任何一般信息都是

有用。我想一些跟踪从托管堆中删除某些东西的方法会有所帮助,虽然我确实删除了我在完成后创建的每个

gcnew对象它(处理它吗?

还有什么我应该做/检查吗?)。但是,如果

这是一个浮动均匀的问题,我甚至不知道如何访问这个

数据......我的意思是,*是*未处理的事件?等待

的指令最终确定?我如何追踪这样的东西?


提前感谢任何信息或指示,

-Moran

Hi,
I''ve been having a problem with C++ Windows Forms apps not "ending"
when you close the form window. I''ve searched about this problem all
over the place and most searches have lead me to believe that this has
to do with unreleased form component events or event handlers.

I''m comparatively new to .net and windows forms, in the sense that
though I''ve been using them for over 2 years now, it''s been rather
sporadic. I work with computer-machine interfaces quite a bit, so I''m
mainly doing ANSI C++/STL so stuff can run on whatever OS the
implementer chooses, and the input is usually handled by an external
component that''s hooked up to this code. Lately though, more and more
instances have risen where a proper user interface was needed, and
Windows Forms has been brilliant in providing an unbelievably fast
development process for even multi-form, parsed-input,
validation-requiring apps. That is, until I decided to get some of the
information processing code inside the app itself...

Up until now, I''ve been creating the input forms, which would then
(after the information was submitted) send this information elsewhere
to be processed. Sometimes this required some additional processing by
another program, and sometimes it just hooked up directly to the
interface which connected to the external element, often some sort of
embedded devide that would cache the data while feeding it to whatever
mechanism was using it.

Now, however, I''ve been presented with a situation where I know that
the client will be using windows-only, and connecting the computer
directly to the device, whichout buffering. So I thought I''d try
simplifying things for everyone and just place everything inside one
C++.net app. This, apparently, held some inherent issues I had no idea
about. Previously, the Forms apps I''ve created just took the data, did
very mild parsing, and output some XML file to be picked up by another
program. Now, the data needs to undergo mathematical manipulation, sent
back to the form to be displayed as a graph, and only then sent out to
the output element. I haven''t even reached the output stage, and it''s
already at a point where most of the time, running the program, working
with it a bit, and closing it, will not end the process. In debug mode,
the form just goes away, but the debugging goes on because the process
is still active.

To clarify, my background is rather "que-centric". Instructions stand
in line, get processed, and then the que moves ahead. This is how my
mind works because I''ve been doing mostly single-threaded C++/STL for
larger scale systems, and C/asm for embedded stuff. All pointer-related
stuff is placed in containers, and so are arrays. If it''s embedded, use
macros to make sure that you don''t leave "things hanging". This may
seem stone-age for windows programmers, but really, even with the
latest PicMicro dsPics, you don''t usually thread. Thus, the whole
notion that you have a person running, throwing a ball up in the air,
keep running, and catching the ball when it falls so as to see what
stuck to it, is very new to me. Moreover, if I have this right, this
isn''t really threading, or is it? Does it have to do with the managed
heap?

I should also mention that the app doesn''t really "need" the user to do
anything in order to remain an open process when the form closes.
Sometimes I run it, and close it almost right away, and it still
remains active. I''ve narrowed down the controls so now there are only
one button, one trackbar, and a panel on which the graph is placed on.
It''s the minimum required elements to have the mathmatical process be
called and then sent back.

So basically, any general information about the subject would be
useful. I suppose some means of tracking when something has been
removed from the managed heap would help, although I do delete every
gcnew object I create when I''m done with it (does that dispose of it?
Is there anything else that I should be doing/checking?). But then, if
this is a "floating even" problem, I don''t even know how to access this
data... I mean, what *is* an unhandled event? An instruction waiting to
be finalized? How do I trace something like that?

Thanks in advance for any info or pointers,
-Moran

推荐答案



< mo ******** @ gmail.comwrote in message

news:11 ***********************@d34g2000cwd.googlegr oups.com ...

<mo********@gmail.comwrote in message
news:11**********************@d34g2000cwd.googlegr oups.com...



当我关闭表单窗口时,我一直遇到C ++ Windows窗体应用程序的问题而不是结束

。我已经在这个地方搜索了这个问题所有

,并且大多数搜索都让我相信这与未发布的表单组件事件或事件处理程序有关。
Hi,
I''ve been having a problem with C++ Windows Forms apps not "ending"
when you close the form window. I''ve searched about this problem all
over the place and most searches have lead me to believe that this has
to do with unreleased form component events or event handlers.



您是否已将表格传递给Application.Run?


您是否可以使用表单的已结束事件来调用Application.Exit?

Did you pass the Form to Application.Run?

Can you just use the Closed event of the Form to call Application.Exit?




Ben Voigt写道:

Ben Voigt wrote:

< mo ********@gmail.com在留言中写道

新闻:11 ********************** @ d34g2000cwd。 googlegr oups.com ...
<mo********@gmail.comwrote in message
news:11**********************@d34g2000cwd.googlegr oups.com...



我一直遇到C ++ Windows窗体应用程序的问题而不是结束 ;关闭表单窗口时,
。我已经在这个地方搜索了这个问题所有

,并且大多数搜索都让我相信这与未发布的表单组件事件或事件处理程序有关。
Hi,
I''ve been having a problem with C++ Windows Forms apps not "ending"
when you close the form window. I''ve searched about this problem all
over the place and most searches have lead me to believe that this has
to do with unreleased form component events or event handlers.



您是否已将表格传递给Application.Run?


您是否可以使用表单的已结束事件来调用Application.Exit?


Did you pass the Form to Application.Run?

Can you just use the Closed event of the Form to call Application.Exit?




从main()调用表单:

Application :: Run(gcnew Form1());


这是由项目建设者完成的,我没有篡改它。当我关闭应用程序时,我的意思是我使用

右上角的常用关闭窗口按钮。我也尝试从表单中调用this-> Close(),

和Application :: Exit(),两者都产生相同的结果 - 表格

关闭,但应用程序,80%的时间,不是。实际上我应该说b $ b可能会说窗体在视觉上闭合,因为我猜测

考虑到它在main()之后什么都没有,除了返回

0,表格实际上还在运行,我只是看不到它......


有什么想法吗?



The form is called from main():
Application::Run(gcnew Form1());

This is done by the project builder, I didn''t tamper with it. When I
close the app, I mean I use the usual close window button on the
top-right. I''ve also tried calling this->Close() from within the form,
and Application::Exit(), both yielding the same result -- the form
closes, but the app, 80% of the time, doesn''t. Actually I should
probably say that the form closes visually, since I''m guessing that
considering there''s nothing after it within main(), apart from return
0, that the form is actually still running, I just can''t see it...

Any ideas?



有什么想法吗?
Any ideas?



进入调试器并查看电话所有线程的堆栈。

主线程在做什么?还有什么其他线程在做什么?

它可能会让你知道发生了什么。


问候,

Oleg

[VC ++ MVP http://www.debuginfo.com/]

Break into debugger and check call stacks of all threads.
What is the main thread doing? What are other threads doing?
It might give you an idea of what is going on.

Regards,
Oleg
[VC++ MVP http://www.debuginfo.com/]


这篇关于Windows窗体应用程序不是“结束”当您关闭窗体窗口时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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