Hi all,
I try to create a service witch handle the session switch events: Lock,
unlocked etc...
I can do this with a standard executable like this (it's just an example):
//*************** *************** **********
//*************** *************** **********
public class Event
{
static WaitHandle[] listhandle = new WaitHandle[] { new
AutoResetEvent( false) };
static public void Main()
{
SessionSwitchEv entHandler handler = new
SessionSwitchEv entHandler(EvHa ndler);
SystemEvents.Se ssionSwitch += handler;
WaitHandle.Wait Any(listhandle) ;
}
static void EvHandler(objec t obj, SessionSwitchEv entArgs args)
{
string str = args.Reason.ToS tring() ;
Console.WriteLi ne(str);
}
}
//*************** *************** **********
//*************** *************** **********
however, when i try to use the same way for my service (i replace the
Console.writeli ne() by a eventlog entry) , nothing is write !!
The service start and run normally but if i locked and unlock my session
nothing is write in my eventlog.
The following is a example of what i try :
//*************** *************** **********
//*************** *************** **********
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeCompo nent();
SessionSwitchEv entHandler handler = new
SessionSwitchEv entHandler(EvHa ndler);
}
private void EvHandler(objec t obj, SessionSwitchEv entArgs args)
{
string str = args.Reason.ToS tring();
this.EventLog.W riteEntry(str, EventLogEntryTy pe.Information) ;
}
protected override void OnStart(string[] args)
{
}
protected override void OnStop()
{
}
}
//*************** *************** **********
//*************** *************** **********
The session Events are not handle by this way, have you any ideas ?
--
Michel