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. Is it possible to catch SystemEvent in Windows service?

Is it possible to catch SystemEvent in Windows service?

Scheduled Pinned Locked Moved C#
helpquestion
2 Posts 2 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.
  • E Offline
    E Offline
    EnkelIk
    wrote on last edited by
    #1

    Hi. Is it possible to catch system events such as SessionEnding in a windows service? I tried to hook on a method to the event, like Microsoft.Win32.SystemEvents.SessionEnding +=new Microsoft.Win32.SessionEndingEventHandler(this.OnSessionEnding); in the OnStart() method but now the service won't start. Is the problem that the service can not catch systemevents at all or have I done something wrong? Thanks /EnkelIk

    A 1 Reply Last reply
    0
    • E EnkelIk

      Hi. Is it possible to catch system events such as SessionEnding in a windows service? I tried to hook on a method to the event, like Microsoft.Win32.SystemEvents.SessionEnding +=new Microsoft.Win32.SessionEndingEventHandler(this.OnSessionEnding); in the OnStart() method but now the service won't start. Is the problem that the service can not catch systemevents at all or have I done something wrong? Thanks /EnkelIk

      A Offline
      A Offline
      ankita patel 0
      wrote on last edited by
      #2

      hi I guess you need to write an event handler function and event handler delegate. see if the following link can be of any help: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfmicrosoftwin32sessionendedeventhandlerclasstopic.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconeventsdelegates.asp all the best. ankita

      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