473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Thread Application cannot be closed completely...

yabansu
14
Hi all,

I use simple threads in my C# application which is a Windows Application having a simple form that contains a start processing and a stop processing button. Program works fine.

But when I try to close the application by clicking the stop processing button, the process does not end even the form closes. In the task manager, that process is seems running in background. I then have to kill that process in order to start it again.

The mouse click event of that button is as the following:

private void stopButton_Click(object sender, EventArgs e)
{
this.Close();
}

If I do not use threads, the exe is being closed completely
.
What do I need to do to solve this problem?
Thanks...
Jan 17 '07 #1
1 1001
nukiee
4
this.Close will close the form that you are working with.

If you have already created a thread, I presume that you have given it a variable name -

System.Threading.Thread t1 = new System.Threading.Thread(new System.Threading.ThreadStart(some_function));
t1.Start();// thread started
t1.Join();// thread is waiting to be finished

Now, if you really want to kill it -

t1.Abort();

Or you can check the status of your thread and take appropriate action based on the status of your thread -

System.Threading.ThreadState t1State = t1.ThreadState;
Jan 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Serge | last post by:
Hi, I am having a thread hang problem in my c# code. The example on the website: http://csharp.web1000.com/ is a simplified version of my problem. You will see in the form that a...
8
by: Gaetan | last post by:
Hi let this code : using System; using System.Threading; namespace ThisNamespace { class ThisClass
3
by: Sean | last post by:
Hi all, I have a few questions here regarding UI thread. (1) If I have two windows A and B, then I call B.show() in A. In this case, there will be only 1 UI thread which is the window A UI...
16
by: bie2 | last post by:
Hi, Here's what I want to do: 1. Start the application. 2. A SplashScreen running in its own thread is started. 3. I'm checking if the application needs an update. 4. If an update is needed...
3
by: Xarky | last post by:
Hi, I have a window, where for a certain event(button click), I am starting a new thread. This thread is retrieving data, creating a new window and displaying it. The window is being shown by...
3
by: Sagaert Johan | last post by:
Hi If i have a form application that creates a thread, is there a way to detect from within that thread if i have closed the form ? Now i use the forms closing event to end the thread i...
7
by: brisers | last post by:
Hello, After studying some of the available resouces ( http://msdn.microsoft.com/msdnmag/issues/04/05/BasicInstincts/default.aspx) I can see that it is forbidden to modify the UI directly from...
5
by: Boki | last post by:
Hi All, When thread returns, that means the thread is closed ? What is the standard way to kill it ? threadA= null ; Thank you for advice! /* CODE BEGIN */
18
by: =?Utf-8?B?VGhlU2lsdmVySGFtbWVy?= | last post by:
Because C# has no native SSH class, I am using SharpSSH. Sometimes, for reasons I do not know, a Connect call will totally lock up the thread and never return. I am sure it has something to do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.