LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-08-2011, 11:23 PM   #1
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
C# question; can't stop application properly


I'm developping a C# app in Windows using VS2010. It has one form and communicates as a client with a server.
A receive thread displays incoming data while buttons and a timer send data. All working.

The form has a button that calls the below method to disconnect from the server.
Code:
        public bool disconnect()
        {
            keepalive_timer.Enabled = false;
            keepalive_timer.Dispose();
            keepalive_timer = null;
            bActive = false;
            tidListen.Abort();
            myClient.Close();
            bConnected = false;
            return false;
        }
It disconnects (I think ) and if I close the form after that, my debug session ends.

I'm however fighting a lost battle to properly stop the application if I close the form using the 'X'. I catch the FormClosing event and call the same disconnect method. But something keeps on running (possibly the thread) and I have to end the debug session manually.

Any pointers where to look or what I'm missing are appreciated.

Thanks in advance,
wimS

PS
The problem was already there before I started using a timer, so I don't think it's in the timer.
 
Old 06-08-2011, 11:45 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

I'm not sure how your application is structured, so I can't recommend all your alternatives ...

... but one "Sure Thing" might be to call "Environment.Exit ()":

http://msdn.microsoft.com/en-us/libr...ment.exit.aspx
 
Old 06-09-2011, 12:16 AM   #3
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Original Poster
Rep: Reputation: 282Reputation: 282Reputation: 282
stupid stupid stupid Somewhere along the line, VS2010 lost the event. Code still there but never invoked

paulsm4, thanks for the time
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 07:24 AM
linux distro question & mysql install question natalie.aloi Linux - Newbie 5 07-19-2009 08:28 PM
Question, Apples Contribution to Open Source + MacOs file structure question Higgy3k Other *NIX 5 07-25-2005 04:23 AM
Not your regular GRUB question - just a short question for a fried MBR!! ziphem Linux - General 3 01-31-2005 01:51 PM
login prompt question & kde scheme question JustinCoyan Slackware 2 06-09-2004 02:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration