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
  1. Home
  2. General Programming
  3. C#
  4. Uneable to stop tcp multithreaded server process

Uneable to stop tcp multithreaded server process

Scheduled Pinned Locked Moved C#
sysadminhelpquestion
4 Posts 4 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.
  • M Offline
    M Offline
    michael wikstrom
    wrote on last edited by
    #1

    I have a problem stopping the server process. Everything seems fine when i stop my multithreaded server, no exceptions when i shut down the application. But the server program wont stop executing. I cant find any more threads that i have forgot to abort. Still if i try to abort the CurrentThread in the end of the program i get an AbortException that cant be handled by the application. Is there something else i can try? Michelangelo

    H S S 3 Replies Last reply
    0
    • M michael wikstrom

      I have a problem stopping the server process. Everything seems fine when i stop my multithreaded server, no exceptions when i shut down the application. But the server program wont stop executing. I cant find any more threads that i have forgot to abort. Still if i try to abort the CurrentThread in the end of the program i get an AbortException that cant be handled by the application. Is there something else i can try? Michelangelo

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Without seeing any code, all I can tell you is that to handle the seemingly uncatchable ThreadAbortException, handle the current AppDomain's AppDomain.UnhandledException event to catch ThreadAbortExceptions (or any others you might want caught).

      Microsoft MVP, Visual C# My Articles

      1 Reply Last reply
      0
      • M michael wikstrom

        I have a problem stopping the server process. Everything seems fine when i stop my multithreaded server, no exceptions when i shut down the application. But the server program wont stop executing. I cant find any more threads that i have forgot to abort. Still if i try to abort the CurrentThread in the end of the program i get an AbortException that cant be handled by the application. Is there something else i can try? Michelangelo

        S Offline
        S Offline
        Spanky3
        wrote on last edited by
        #3

        Hi, I presume your server is using a thread which continually listens on a port by running it on a thread. Currently when you close your program down the lightweight process (the thread) continues to be executed. In the applications "closing" event you need to ensure all threads running are interrupted and cleaned up. Dont use the STOP method as it is very bad.. you could end up with part written data for the instance of the program. Theres a pretty complete guide here on threads: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchusingthreads.asp[^] Which is worth a glance, but for the quick solution do this in the closing event for the main form/application: threadinstance.Interrupt();

        1 Reply Last reply
        0
        • M michael wikstrom

          I have a problem stopping the server process. Everything seems fine when i stop my multithreaded server, no exceptions when i shut down the application. But the server program wont stop executing. I cant find any more threads that i have forgot to abort. Still if i try to abort the CurrentThread in the end of the program i get an AbortException that cant be handled by the application. Is there something else i can try? Michelangelo

          S Offline
          S Offline
          scadaguy
          wrote on last edited by
          #4

          The threads you have created may be foreground threads. These threads will keep the process running until they stop. Try setting the Thread.IsBackground property to true. Once all foreground threads have stopped executing the runtime will abort all background threads automatically.

          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