Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Need to kill thread when application is closed

Need to kill thread when application is closed

Scheduled Pinned Locked Moved .NET (Core and Framework)
databasehelptutorial
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amit Sk Sharma
    wrote on last edited by
    #1

    on top right or Alt+f4 etc.), threads and process both should get terminated but actually my application still remains there in Task Mgr process list and threads continue their execution.
    Please let me know how to terminate threads and process explicitly. I made RnD on google and applied some of work-around but in vain.

    With Thanks & Regards Amit Sk Sharma

    L L 2 Replies Last reply
    0
    • A Amit Sk Sharma

      on top right or Alt+f4 etc.), threads and process both should get terminated but actually my application still remains there in Task Mgr process list and threads continue their execution.
      Please let me know how to terminate threads and process explicitly. I made RnD on google and applied some of work-around but in vain.

      With Thanks & Regards Amit Sk Sharma

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Amit for .NET wrote:

      Please let me know how to terminate threads and process explicitly.

      Thread.Abort[^] Although it'd be neater to signal the thread that your app is exiting and have the thread exit normally.

      Amit for .NET wrote:

      I made RnD on google and applied some of work-around but in vain.

      Some things can't be patched by copying code; you'll have to reserve some time and dive into the concepts.

      I are Troll :suss:

      A 1 Reply Last reply
      0
      • A Amit Sk Sharma

        on top right or Alt+f4 etc.), threads and process both should get terminated but actually my application still remains there in Task Mgr process list and threads continue their execution.
        Please let me know how to terminate threads and process explicitly. I made RnD on google and applied some of work-around but in vain.

        With Thanks & Regards Amit Sk Sharma

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        if you set Thread.IsBackground true, the thread will not prevent your app to exit right away when you choose to terminate it. BTW: ThreadPool threads (and hence also BackgroundWorker threads) always are background threads. :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        A 1 Reply Last reply
        0
        • L Lost User

          Amit for .NET wrote:

          Please let me know how to terminate threads and process explicitly.

          Thread.Abort[^] Although it'd be neater to signal the thread that your app is exiting and have the thread exit normally.

          Amit for .NET wrote:

          I made RnD on google and applied some of work-around but in vain.

          Some things can't be patched by copying code; you'll have to reserve some time and dive into the concepts.

          I are Troll :suss:

          A Offline
          A Offline
          Amit Sk Sharma
          wrote on last edited by
          #4

          I just took a reference from google, not copied.but yes I think 'm lacking sm whr with concepts so 'm here. exactly what I m looking for is how to manage the threads and process through code in desktop application when my application terminates unexpectedly.

          With Thanks & Regards Amit Sk Sharma

          L 1 Reply Last reply
          0
          • L Luc Pattyn

            if you set Thread.IsBackground true, the thread will not prevent your app to exit right away when you choose to terminate it. BTW: ThreadPool threads (and hence also BackgroundWorker threads) always are background threads. :)

            Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

            A Offline
            A Offline
            Amit Sk Sharma
            wrote on last edited by
            #5

            I m already using this, when I close application, window is closed but process and thread both continues with their execution. experimenting with background worker, will respond soon if target achieved.

            With Thanks & Regards Amit Sk Sharma

            L 1 Reply Last reply
            0
            • A Amit Sk Sharma

              I m already using this, when I close application, window is closed but process and thread both continues with their execution. experimenting with background worker, will respond soon if target achieved.

              With Thanks & Regards Amit Sk Sharma

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              Amit for .NET wrote:

              thread both continues with their execution.

              That is impossible, I suggest you check your code thoroughly. Background threads don't keep a process alive, only foreground threads do. :)

              Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

              Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

              1 Reply Last reply
              0
              • A Amit Sk Sharma

                I just took a reference from google, not copied.but yes I think 'm lacking sm whr with concepts so 'm here. exactly what I m looking for is how to manage the threads and process through code in desktop application when my application terminates unexpectedly.

                With Thanks & Regards Amit Sk Sharma

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                The problem will be gone as soon as you've switched to a backgroundworker; those threads get terminated when the proces is terminated. A foreground-thread is rarely used, but if required, you'd signal it and have it save any remaining data and terminate.

                I are Troll :suss:

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups