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. Process.Kill() problem

Process.Kill() problem

Scheduled Pinned Locked Moved C#
helpquestionhardwaretutoriallearning
1 Posts 1 Posters 1 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
    Mel Feik
    wrote on last edited by
    #1

    I have a simple application timer program - allows any executable to launched, with command line arguments (optional) and terminates after specified number of minutes. Here's how I'm currently terminating timed process:

    while (true)
    {
    //keep checking if timer expired or app closed externally (ie. by user)
    if (dtEndTime <= DateTime.Now || p.HasExited)
    {
    if (!p.HasExited)
    p.Kill();
    break;
    }
    System.Threading.Thread.Sleep(500);
    }

    Rather straight forward and works most of the time. A crash occurs when I am timing a program called Fraps.exe and its minimized to the tray. The crash itself doesn't always have the same results. What is consistant is: - the app Kill() is called for IS closed - a crash occurs What varies: - another app in the tray will crash as well (intermittently) If I do not minimize Fraps.exe to the tray no crash occurs (however, leaving it on the desktop is not an acceptable solution). Fraps can be closed via task manager without issue. Any suggestions on how to terminate an external application more gracefully? Process.Close() and Process.CloseMainWindow() have already be ruled out for the case of being in the tray. I'm open to anything will work and not cause a crash.

    --------------------------------------------- Help... I'm embedded and I can't get out! If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler

    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