Solved

Application that won't close

Posted on 2004-04-29
9
366 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

828 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