Solved

Application that won't close

Posted on 2004-04-29
9
369 Views
Last Modified: 2010-04-15
Hi,

I have an application, which, after a certain set of actions, refuses to close.

I can reproduce this consistently..

Using one method, I open a form, click any of a range of buttons (I've even removed the code from the button), then closed the form.
Using another method, I open a form, then closed it straight away.

Following the first method, anything I try to do to close the application is ignored.
Following the second, it closes normally.

This seems to me that either a thread is being left running somewhere or something else is preventing the form from closing.. has anyone come across this before ??

Smg.
0
Comment
Question by:smegghead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 10955106
http://www.jelovic.com/weblog/e41.htm

if this is not the issue I bet that it is still a controls validation failing during the close method

0
 
LVL 25

Expert Comment

by:nauman_ahmed
ID: 10955402
Is it possible for you to put the code here. Just wanted to see how you are trying to close the form.

Thanks, Nauman
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10956366
what is the meaning third link here ? Is this a mis copy/paste ?
0
 
LVL 21

Expert Comment

by:tovvenki
ID: 10956789
Hi,
if you have done any validation checks like

private void textBox1_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
    'if condition not satisfied then
    ' e.Cancel = true;
}

this will prevent the form from getting closed(I have experienced this behaviour). Please check that.

I hope that this helps you.

Regards,
Venki
0
 
LVL 10

Author Comment

by:smegghead
ID: 10957659
gregory, you could just be a lifesaver, that looks very hopeful.. I will just have to implement the workaround now.

Rama.. More irrelevant links ?? I'm sure most people who ask questions do a simple web-search before asking, I've wasted quite a bit of time in previous questions reading through long pages (posted by you) only to find nothing relevant. Have you got a program that goes through all questions on EE, does a search in google, then posts a 'comment' in ee with the top 3 results ??
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10957753
I hope that is the problem if not you can email me the code and I can try stepping through it to see what might be going on.

btw: If this were a threading issue the behavior would be slightly different. The behavior I have always experienced in a thread issue was that forms would close (as if they exited) but then if you went into your running processes the app was still alive.
0
 
LVL 10

Author Comment

by:smegghead
ID: 10957905
Yeah, I've encountered the same problem with threads too.

I'm fairly sure after reading the article you posted it will sort it.

Thanks for the offer.. maybe if that doesn't work and you have any other ideas, you could do a 'remote assistance' to me.. but I don't think that will be necessary

Thanks again.. I'll post the points when I'm sure that was the problem.

Smg.
0
 
LVL 10

Author Comment

by:smegghead
ID: 10958603
Well, it turns out it wasn't the same issue as mentioned above relating to OnControlRemoved.

I solved this by programatically going through all controls, and their subsequent children, removing them all.. it then allowed me to close the form.

I'll award the points to Gregory, as he pointed me in the right direction.

Here's the code I used to close all controls etc..

private void TryClose(System.Windows.Forms.Control MyParent,System.Windows.Forms.Control zis)
{
      while (zis.Controls.Count>0)
      {
            TryClose(zis,zis.Controls[0]);
      }
      if (MyParent!=null)
      {
            MyParent.Controls.Remove(zis);
      }
}


private void MyPanelView_Close(object sender, System.EventArgs e)
{
      TryClose(null,this);
}

My App is quite complex in the way panels etc are arranged.. I basically have a main form which contains a tabcontrol, then each tab page contains a class derived from panel, which in turn contains multiple controls.

I'm sure this is a windows bug, as I shouldn't have to manually remove each control. Maybe I'm missing something somewhere.

Thanks anyway.
Smg.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question