Solved

Application that won't close

Posted on 2004-04-29
9
362 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

929 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

9 Experts available now in Live!

Get 1:1 Help Now