Solved

Application that won't close

Posted on 2004-04-29
9
364 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
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
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10955900
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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