Solved

Application that won't close

Posted on 2004-04-29
9
361 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
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 10956366
what is the meaning third link here ? Is this a mis copy/paste ?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Email Body 4 47
Default parameter problem in C# 3 27
C# DataGridView_RowsAdded event not firing 1 40
Round up to 100% in .NET 10 46
Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now