Is there is any event handler for process kill event ?

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

    Is there is any event handler for process kill event ?

    Hi,

    I am looking for doing this :

    void OnKillProcess()
    {
    do Cleanup;
    }

    i don't want to use ~MyClass() (or Finalize), because i wan't that
    the cleanup code will be call from my main thread and not from any other
    thread.

    thanks.

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

    #2
    Re: Is there is any event handler for process kill event ?

    Hi,

    Did you try Application.App licationExit event?

    cheers,

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



    "yaron" <yaron@discussi ons.microsoft.c om> wrote in message
    news:7DC060A6-89D3-4280-86ED-DFC535EB3471@mi crosoft.com...[color=blue]
    > Hi,
    >
    > I am looking for doing this :
    >
    > void OnKillProcess()
    > {
    > do Cleanup;
    > }
    >
    > i don't want to use ~MyClass() (or Finalize), because i wan't that
    > the cleanup code will be call from my main thread and not from any other
    > thread.
    >
    > thanks.
    >[/color]


    Comment

    • yaron

      #3
      Re: Is there is any event handler for process kill event ?

      Hi Ignacio Machin,

      I am writing C# Console application and not WinForms application, because i
      saw that the application class is part of the syste.windows.f orms namespace.
      i tried to use it in console application and it didn't work.

      thanks.


      "Ignacio Machin ( .NET/ C# MVP )" wrote:
      [color=blue]
      > Hi,
      >
      > Did you try Application.App licationExit event?
      >
      > cheers,
      >
      > --
      > Ignacio Machin,
      > ignacio.machin AT dot.state.fl.us
      > Florida Department Of Transportation
      >
      >
      >
      > "yaron" <yaron@discussi ons.microsoft.c om> wrote in message
      > news:7DC060A6-89D3-4280-86ED-DFC535EB3471@mi crosoft.com...[color=green]
      > > Hi,
      > >
      > > I am looking for doing this :
      > >
      > > void OnKillProcess()
      > > {
      > > do Cleanup;
      > > }
      > >
      > > i don't want to use ~MyClass() (or Finalize), because i wan't that
      > > the cleanup code will be call from my main thread and not from any other
      > > thread.
      > >
      > > thanks.
      > >[/color]
      >
      >
      >[/color]

      Comment

      • Brendan Grant

        #4
        Re: Is there is any event handler for process kill event ?

        Add a reference to System.Windows. Forms.dll to get access to the Application
        class.

        Brendan


        "yaron" wrote:
        [color=blue]
        > Hi Ignacio Machin,
        >
        > I am writing C# Console application and not WinForms application, because i
        > saw that the application class is part of the syste.windows.f orms namespace.
        > i tried to use it in console application and it didn't work.
        >
        > thanks.
        >
        >
        > "Ignacio Machin ( .NET/ C# MVP )" wrote:
        >[color=green]
        > > Hi,
        > >
        > > Did you try Application.App licationExit event?
        > >
        > > cheers,
        > >
        > > --
        > > Ignacio Machin,
        > > ignacio.machin AT dot.state.fl.us
        > > Florida Department Of Transportation
        > >
        > >
        > >
        > > "yaron" <yaron@discussi ons.microsoft.c om> wrote in message
        > > news:7DC060A6-89D3-4280-86ED-DFC535EB3471@mi crosoft.com...[color=darkred]
        > > > Hi,
        > > >
        > > > I am looking for doing this :
        > > >
        > > > void OnKillProcess()
        > > > {
        > > > do Cleanup;
        > > > }
        > > >
        > > > i don't want to use ~MyClass() (or Finalize), because i wan't that
        > > > the cleanup code will be call from my main thread and not from any other
        > > > thread.
        > > >
        > > > thanks.
        > > >[/color]
        > >
        > >
        > >[/color][/color]

        Comment

        • yaron

          #5
          Re: Is there is any event handler for process kill event ?

          Hi Brendan Grant,

          I already did it (add reference), and it didn't work.

          thanks.


          "Brendan Grant" wrote:
          [color=blue]
          > Add a reference to System.Windows. Forms.dll to get access to the Application
          > class.
          >
          > Brendan
          >
          >
          > "yaron" wrote:
          >[color=green]
          > > Hi Ignacio Machin,
          > >
          > > I am writing C# Console application and not WinForms application, because i
          > > saw that the application class is part of the syste.windows.f orms namespace.
          > > i tried to use it in console application and it didn't work.
          > >
          > > thanks.
          > >
          > >
          > > "Ignacio Machin ( .NET/ C# MVP )" wrote:
          > >[color=darkred]
          > > > Hi,
          > > >
          > > > Did you try Application.App licationExit event?
          > > >
          > > > cheers,
          > > >
          > > > --
          > > > Ignacio Machin,
          > > > ignacio.machin AT dot.state.fl.us
          > > > Florida Department Of Transportation
          > > >
          > > >
          > > >
          > > > "yaron" <yaron@discussi ons.microsoft.c om> wrote in message
          > > > news:7DC060A6-89D3-4280-86ED-DFC535EB3471@mi crosoft.com...
          > > > > Hi,
          > > > >
          > > > > I am looking for doing this :
          > > > >
          > > > > void OnKillProcess()
          > > > > {
          > > > > do Cleanup;
          > > > > }
          > > > >
          > > > > i don't want to use ~MyClass() (or Finalize), because i wan't that
          > > > > the cleanup code will be call from my main thread and not from any other
          > > > > thread.
          > > > >
          > > > > thanks.
          > > > >
          > > >
          > > >
          > > >[/color][/color][/color]

          Comment

          • Willy Denoyette [MVP]

            #6
            Re: Is there is any event handler for process kill event ?

            This event is not raised as a result of a 'kill' command, note also that
            Console applications can't use this event either, only applications that
            have a message loop can register for this event, and the event is fired as a
            result of Application.Exi t to be called.
            Willy.

            "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
            in message news:%23QZWsSGj FHA.2772@TK2MSF TNGP12.phx.gbl. ..[color=blue]
            > Hi,
            >
            > Did you try Application.App licationExit event?
            >
            > cheers,
            >
            > --
            > Ignacio Machin,
            > ignacio.machin AT dot.state.fl.us
            > Florida Department Of Transportation
            >
            >
            >
            > "yaron" <yaron@discussi ons.microsoft.c om> wrote in message
            > news:7DC060A6-89D3-4280-86ED-DFC535EB3471@mi crosoft.com...[color=green]
            >> Hi,
            >>
            >> I am looking for doing this :
            >>
            >> void OnKillProcess()
            >> {
            >> do Cleanup;
            >> }
            >>
            >> i don't want to use ~MyClass() (or Finalize), because i wan't that
            >> the cleanup code will be call from my main thread and not from any other
            >> thread.
            >>
            >> thanks.
            >>[/color]
            >
            >[/color]


            Comment

            • Willy Denoyette [MVP]

              #7
              Re: Is there is any event handler for process kill event ?

              There is nothing yu can do when a process gets killed ( a result of a
              ApplicationExit call), the process simply disappears without any possibility
              to execute any code.

              Willy.

              "yaron" <yaron@discussi ons.microsoft.c om> wrote in message
              news:DBACB4F2-6987-4934-8ADF-C302121B2017@mi crosoft.com...[color=blue]
              > Hi Brendan Grant,
              >
              > I already did it (add reference), and it didn't work.
              >
              > thanks.
              >
              >
              > "Brendan Grant" wrote:
              >[color=green]
              >> Add a reference to System.Windows. Forms.dll to get access to the
              >> Application
              >> class.
              >>
              >> Brendan
              >>
              >>
              >> "yaron" wrote:
              >>[color=darkred]
              >> > Hi Ignacio Machin,
              >> >
              >> > I am writing C# Console application and not WinForms application,
              >> > because i
              >> > saw that the application class is part of the syste.windows.f orms
              >> > namespace.
              >> > i tried to use it in console application and it didn't work.
              >> >
              >> > thanks.
              >> >
              >> >
              >> > "Ignacio Machin ( .NET/ C# MVP )" wrote:
              >> >
              >> > > Hi,
              >> > >
              >> > > Did you try Application.App licationExit event?
              >> > >
              >> > > cheers,
              >> > >
              >> > > --
              >> > > Ignacio Machin,
              >> > > ignacio.machin AT dot.state.fl.us
              >> > > Florida Department Of Transportation
              >> > >
              >> > >
              >> > >
              >> > > "yaron" <yaron@discussi ons.microsoft.c om> wrote in message
              >> > > news:7DC060A6-89D3-4280-86ED-DFC535EB3471@mi crosoft.com...
              >> > > > Hi,
              >> > > >
              >> > > > I am looking for doing this :
              >> > > >
              >> > > > void OnKillProcess()
              >> > > > {
              >> > > > do Cleanup;
              >> > > > }
              >> > > >
              >> > > > i don't want to use ~MyClass() (or Finalize), because i wan't that
              >> > > > the cleanup code will be call from my main thread and not from any
              >> > > > other
              >> > > > thread.
              >> > > >
              >> > > > thanks.
              >> > > >
              >> > >
              >> > >
              >> > >[/color][/color][/color]


              Comment

              • yaron

                #8
                Re: Is there is any event handler for process kill event ?

                Hi Willy Denoyette,

                so if i understand you, the one and only option for console app is to put my
                cleanup code in ~MyClass() ?

                Thanks.


                "Willy Denoyette [MVP]" wrote:
                [color=blue]
                > This event is not raised as a result of a 'kill' command, note also that
                > Console applications can't use this event either, only applications that
                > have a message loop can register for this event, and the event is fired as a
                > result of Application.Exi t to be called.
                > Willy.
                >
                > "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
                > in message news:%23QZWsSGj FHA.2772@TK2MSF TNGP12.phx.gbl. ..[color=green]
                > > Hi,
                > >
                > > Did you try Application.App licationExit event?
                > >
                > > cheers,
                > >
                > > --
                > > Ignacio Machin,
                > > ignacio.machin AT dot.state.fl.us
                > > Florida Department Of Transportation
                > >
                > >
                > >
                > > "yaron" <yaron@discussi ons.microsoft.c om> wrote in message
                > > news:7DC060A6-89D3-4280-86ED-DFC535EB3471@mi crosoft.com...[color=darkred]
                > >> Hi,
                > >>
                > >> I am looking for doing this :
                > >>
                > >> void OnKillProcess()
                > >> {
                > >> do Cleanup;
                > >> }
                > >>
                > >> i don't want to use ~MyClass() (or Finalize), because i wan't that
                > >> the cleanup code will be call from my main thread and not from any other
                > >> thread.
                > >>
                > >> thanks.
                > >>[/color]
                > >
                > >[/color]
                >
                >
                >[/color]

                Comment

                Working...