473,320 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

System Events

Hi.
I'm trying to handle the SessionEnding event in
Microsoft.Win32.SystemEvents, but when I hook up my event handler it throws
an exception. I don't recognize the exception and I'm not sure whether it has
anything to do with the fact I'm using it in a Windows Service. The exception
is given below.
Thanks for your assistance.
Reuben
================================================== ===
System.Runtime.InteropServices.ExternalException: Failed to create system
events window thread.
at Microsoft.Win32.SystemEvents.EnsureSystemEvents(Bo olean requireHandle,
Boolean throwOnRefusal)
at
Microsoft.Win32.SystemEvents.add_SessionEnding(Ses sionEndingEventHandler
value)
at Symbiosis.Symbiosis.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMai nCallback(Object
state).
Oct 3 '05 #1
2 1645
Reuben wrote:
Hi.
I'm trying to handle the SessionEnding event in
Microsoft.Win32.SystemEvents, but when I hook up my event handler it throws
an exception. I don't recognize the exception and I'm not sure whether it has
anything to do with the fact I'm using it in a Windows Service. The exception
is given below.


I'm not sure it is necessary to hook the SessionEnding event in your
Windows Service. When Windows shuts down, the Service Control Manager
will stop your service. You should be able to do any necessary code in
the OnStop handler of your service.

Oct 3 '05 #2
Yes, but I need to be able to CANCEL the event if neccessary; hence the use
of the event.
Oct 4 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex | last post by:
I am trying to determine if C# has the capabilities to listen for system events when the application does not have the window's focus. I am writing a windows application that I would like to run...
3
by: Bob | last post by:
Is there an interface or events in the system that occurs pre and post garbage collection that one of my objects can attach to? I need to know in my application when garbage collection is about to...
3
by: awong | last post by:
Hi there, I was trying to convert the following VB6 code to VB.NET. But I can't find a corresponding System.XML object for MSXML IXMLDOMSelection. I am thinking to use System.XML XMLNodeList...
2
by: Aaron Queenan | last post by:
Is there any way to know whether the OnItemCheck is being called in response to a user action (mouse or keyboard) as opposed to the form loading? I have a class which derives from...
0
by: Dave McIver | last post by:
Hello all, Any help on this issue appreciated because I am getting a bit stuck! I am using VS.NET 2003. I have wrapped a multithreaded win32 dll using managed C++ and added a C# interface,...
6
by: Scotty | last post by:
What function is called in response to a click on "Close" on system menu (the "X" in the top right side of window)?
4
by: Ben | last post by:
Hello everybody I got confused by this problem for which I don't have a logical explanation. There is a Thread (ThreadA) which receives Events from another system thread (ThreadS). ThreadA then...
3
by: geskerrett | last post by:
We have been asked to develop and application for a client that is a 'notification" system. We would like to use python, but are struggling to find the right starting point. Any suggestions, tips...
1
by: josh | last post by:
Hi, I have several independent, system components that write audit events to a database locally via ODBC and remotely via TCP, and I have a requirement to audit when the database is available for...
5
by: Tony Gravagno | last post by:
I have a class that instantiates two Timer objects that fire at different intervals. My class can be instantiated within a Windows Form or from a Windows Service. Actions performed by one of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.