Process.CloseMainWindow()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy

    #1

    Process.CloseMainWindow()

    Is there a way to force a window to close without displaying a popup asking:
    "Windows cannot end this program....If you choose to end the program
    immediately, you will lose any unsaved data."

    This is a process I am calling and controlling through the code, but I
    defiantely want the process to close the window without any user
    intervention. Can I force this to close?

    The Process.CloseMa inWindow() does not seem to have any overrides that will
    simulate the "End Now" button.

    Thanks
    Andy
  • Mehdi

    #2
    Re: Process.CloseMa inWindow()

    On Fri, 24 Feb 2006 09:55:30 -0800, Andy wrote:
    [color=blue]
    > Is there a way to force a window to close without displaying a popup asking:
    > "Windows cannot end this program....If you choose to end the program
    > immediately, you will lose any unsaved data."
    >
    > This is a process I am calling and controlling through the code, but I
    > defiantely want the process to close the window without any user
    > intervention. Can I force this to close?[/color]

    That would be Process.Kill() then if you want to kill the process. Not very
    clean though. You could try to close it normally, then wait a few seconds
    for it to close and kill it eventually if it really refuses to close by
    itself. Sounds better to me.

    Comment

    • Ignacio Machin \( .NET/ C# MVP \)

      #3
      Re: Process.CloseMa inWindow()

      Hi,

      Process.Kill is your answer, note that this does nothing to allow the
      process to terminate in a nice way.

      Process.CloseMa inWindow should be prefered.


      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation

      "Andy" <Andy@discussio ns.microsoft.co m> wrote in message
      news:8A9F9FD1-850B-4CE7-B5EB-2C913741839A@mi crosoft.com...[color=blue]
      > Is there a way to force a window to close without displaying a popup
      > asking:
      > "Windows cannot end this program....If you choose to end the program
      > immediately, you will lose any unsaved data."
      >
      > This is a process I am calling and controlling through the code, but I
      > defiantely want the process to close the window without any user
      > intervention. Can I force this to close?
      >
      > The Process.CloseMa inWindow() does not seem to have any overrides that
      > will
      > simulate the "End Now" button.
      >
      > Thanks
      > Andy[/color]


      Comment

      • Andy

        #4
        Re: Process.CloseMa inWindow()

        Thanks for the suggestion, but the odd thing is: when I use Process.Kill,
        the main window does not close, but remains open, which is why I was trying
        to use the CloseMainWindow () method.

        For some reason: when I issue a Process.Kill, the process itself is killed,
        but the user window remains open, which is causing an issue.

        Thanks
        Andy

        "Ignacio Machin ( .NET/ C# MVP )" wrote:
        [color=blue]
        > Hi,
        >
        > Process.Kill is your answer, note that this does nothing to allow the
        > process to terminate in a nice way.
        >
        > Process.CloseMa inWindow should be prefered.
        >
        >
        > --
        > Ignacio Machin,
        > ignacio.machin AT dot.state.fl.us
        > Florida Department Of Transportation
        >
        > "Andy" <Andy@discussio ns.microsoft.co m> wrote in message
        > news:8A9F9FD1-850B-4CE7-B5EB-2C913741839A@mi crosoft.com...[color=green]
        > > Is there a way to force a window to close without displaying a popup
        > > asking:
        > > "Windows cannot end this program....If you choose to end the program
        > > immediately, you will lose any unsaved data."
        > >
        > > This is a process I am calling and controlling through the code, but I
        > > defiantely want the process to close the window without any user
        > > intervention. Can I force this to close?
        > >
        > > The Process.CloseMa inWindow() does not seem to have any overrides that
        > > will
        > > simulate the "End Now" button.
        > >
        > > Thanks
        > > Andy[/color]
        >
        >
        >[/color]

        Comment

        Working...