Thread Application cannot be closed completely...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yabansu
    New Member
    • Dec 2006
    • 14

    Thread Application cannot be closed completely...

    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_Clic k(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...
  • nukiee
    New Member
    • Jan 2007
    • 4

    #2
    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.Threadin g.Thread t1 = new System.Threadin g.Thread(new System.Threadin g.ThreadStart(s ome_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.Threadin g.ThreadState t1State = t1.ThreadState;

    Comment

    Working...