Results 1 to 7 of 7

Thread: [RESOLVED] Process in Taskmanager

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    40

    Resolved [RESOLVED] Process in Taskmanager

    hello
    I have a codded a small application with on thread other than main.when close the application through programatically it still shows in task manager.The code
    is
    mythread.abort()
    close()
    these are the events of a button click.Please guide me
    RAO

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Process in Taskmanager

    Are you handling the ThreadAbortException that gets thrown? If not then there's no point aborting the thread. If you aren't going to do any cleanup then simply set the IsBackground property of the Thread to True before you Start it and it won't stop the process ending.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    40

    Re: Process in Taskmanager

    i put it in try catch.sometimes the process closes in taskmanager and sometimes it is visible in taskmanager using 40 to 50% of cpu.my thread runs a loop before it is suspended or aborted.My intention is when we click the close button the thread should stop or abort and my application should terminate with out showing in taskmanager.
    RAO

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Process in Taskmanager

    Are you performing any clean up? If not then aborting a foreground thread is pointless. Make it a background thread and the problem disappears. There's no need to abort because the thread will simply be terminated automatically.

    That said, you really should ask yourself whether you SHOULD be performing some clean up. Maybe it's not required, but maybe it is.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    40

    Re: Process in Taskmanager

    Thank You Friend
    As you said I made it background.The Problem solved
    RAO

  6. #6
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: Process in Taskmanager

    If your problem has been solved, then select Thread Tools -> Mark Thread Resolved

    On another note however, termination of threads can cause a lot of problems, especially when these threads are holding DB or server connections, or executing un-managed code. May we see the actual code being run in your alternate thread?

  7. #7

    Thread Starter
    Member
    Join Date
    Aug 2006
    Posts
    40

    Re: [RESOLVED] Process in Taskmanager

    Hi Maxi
    I still at the stage of learning.Actually the app which I talked about is my first app using a thread.I think the other thread is only main thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width