Hello Group,
I'm writting a Windows Services under C# to get some USB events. Because the ServiceBase class does not supports the SERVICE_CONTROL _DEVICEEVENT handler, I'm using P/Invoke to call the RegisterService CtrlHandlerEx funtion, using a callback to manage the needed handler. The invoke looks ok, it works.
The problem is when the services stops. My callback function receives the SERVICE_CONTROL _STOP handler but the function don't return. The Services Control shows an Error like: "The Services "myService" could not be stopped". The Service did not returned an error code.
If i hook my debug code to the service and try to stop the service again after the Error Message. I get the cursor in the Dispose function.
I think that with the calling of the ...Ex function, I have to do something more than to "return 0" when the SERVICE_CONTROL _STOP handler is received, .. Know somebody what should it be?
Thanks in advance.
--
KW 1 5265
Already found. I have to call the ServiceBase.Sto p() when receiving the SERVICE_CONTROL _STOP in the HandlerEx callback funtion. Now is all ok.. nevertheless thanks .
KW.
"McKool" <ke*****@peak-system.comschri eb im Newsbeitrag news:uH******** ******@TK2MSFTN GP02.phx.gbl...
Hello Group,
I'm writting a Windows Services under C# to get some USB events. Because the ServiceBase class does not supports the SERVICE_CONTROL _DEVICEEVENT handler, I'm using P/Invoke to call the RegisterService CtrlHandlerEx funtion, using a callback to manage the needed handler. The invoke looks ok, it works.
The problem is when the services stops. My callback function receives the SERVICE_CONTROL _STOP handler but the function don't return. The Services Control shows an Error like: "The Services "myService" could not be stopped". The Service did not returned an error code.
If i hook my debug code to the service and try to stop the service again after the Error Message. I get the cursor in the Dispose function.
I think that with the calling of the ...Ex function, I have to do something more than to "return 0" when the SERVICE_CONTROL _STOP handler is received, .. Know somebody what should it be?
Thanks in advance.
--
KW This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Adam Clauss |
last post by:
I have a C# Windows Service running as the NetworkService account because it
needs to access a network share.
As part of the service's initialization, I want the service to terminate, if
an unrecoverable error occurs. When that case occurs, I create a
ServiceController object and call the Stop() method.
However - I get an exception thrown saying access denied. If I switch to
using the LocalService account it works fine, but I lose...
|
by: Frank Rizzo |
last post by:
Hello,
My c# based windows service takes a while to dispose. I have to release
bunch of resources all over the place and unfortunately it can take
20-40 seconds before I can cleanly exit.
Every now and then, when I stop the service from the Services applet, it
will timeout and bring up an error message saying that the service isn't
responding.
|
by: gregory_may |
last post by:
According to this article, I cant change "CanStop" on the fly!!!
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemserviceprocessservicebaseclasscanstoptopic.asp
So, how can I enable/disable the ability for a user to kill my service (Via
Task Manager) on the fly?
I would prefer not to tweak the regestry settings that permit Task manager
from be available to a user. I have not had good luck down...
|
by: Sunil Varma |
last post by:
Hello all,
I wrote a Windows Service in VC.NET 2005
I want to debug the solution.
I tried as mentioned in the following link.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconintroductiontontserviceapplications.asp
But, when I started the service I got a message box saying that the
service is being stopped.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |