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. Hanlde Event when C# exe is aborted abruptly

Hanlde Event when C# exe is aborted abruptly

Scheduled Pinned Locked Moved C#
csharpquestion
5 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.
  • H Offline
    H Offline
    harvid
    wrote on last edited by
    #1

    Hi all, I have a windows C# EXE. In most cases, it will be killed abruptly from TaskManager (its session will be killed). Is there any Event in C# to handle those abruptly closing of EXE? Need in urgent. Thanx in advance vidh

    O D P 3 Replies Last reply
    0
    • H harvid

      Hi all, I have a windows C# EXE. In most cases, it will be killed abruptly from TaskManager (its session will be killed). Is there any Event in C# to handle those abruptly closing of EXE? Need in urgent. Thanx in advance vidh

      O Offline
      O Offline
      originSH
      wrote on last edited by
      #2

      If you kill something from the task manager the idea is that it should stop dead right there and then. Before Vista you were trusted to be able to hook into the system shutdown events and even stop the shutdown if needed. THis was abused way too much and iirc Vista now will notify you, give you a few seconds, and then carry on anyway. It'd be just the same with a kill command from the task manager, if the OS allowed you to intervine it would be abused a lot and so just isn't there. On a personal note if I tried to kill an app and it declined I would be very angry, it's my machine and I know what I want to happen better than the app does, I didn't click End Process by accident!

      1 Reply Last reply
      0
      • H harvid

        Hi all, I have a windows C# EXE. In most cases, it will be killed abruptly from TaskManager (its session will be killed). Is there any Event in C# to handle those abruptly closing of EXE? Need in urgent. Thanx in advance vidh

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        harvid wrote:

        Is there any Event in C# to handle those abruptly closing of EXE?

        TaskManager will TRY and close the app nicely first. This is a normal close event on the main form of your application. If your app doesn't respond, it'll just be stopped and killed. There is no event and no chance for your code to even care. It's the "bullet in the brain" method of killing your app.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        1 Reply Last reply
        0
        • H harvid

          Hi all, I have a windows C# EXE. In most cases, it will be killed abruptly from TaskManager (its session will be killed). Is there any Event in C# to handle those abruptly closing of EXE? Need in urgent. Thanx in advance vidh

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          Like Dave and originSH said, the purpose of the task manager is to stop a task/process pretty much in it's tracks. You can try the OnClose method, but it might not do you a whole alot. Letting task manager do it's bit by shutting down the app with no intervention done by the app is what should be intended. Nothing more irritating than telling task manager over and over to kill a process because it won't go away.

          "The clue train passed his station without stopping." - John Simmons / outlaw programmer

          H 1 Reply Last reply
          0
          • P Paul Conrad

            Like Dave and originSH said, the purpose of the task manager is to stop a task/process pretty much in it's tracks. You can try the OnClose method, but it might not do you a whole alot. Letting task manager do it's bit by shutting down the app with no intervention done by the app is what should be intended. Nothing more irritating than telling task manager over and over to kill a process because it won't go away.

            "The clue train passed his station without stopping." - John Simmons / outlaw programmer

            H Offline
            H Offline
            harvid
            wrote on last edited by
            #5

            Hi Dave,Paul and originSH, Thanks a lot for your comments. Let me explain my actual scenario, I have a C# Windows EXE which will call my Webserive hosted in another Webserver asynchronously. We have an UI interface which will call the above mentioned C# Windows EXE. when EXE gets abruptly aborted from UI Interface, my webservice still running in webserver machine. Any options or methods to stop my webservice when my EXE stops abruptly? Pls help me out. Thx Vidh

            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