windows-services

HttpContext.Current.Server null

与世无争的帅哥 提交于 2019-12-17 16:59:21
问题 I have a windows service which is using a method from a class library with same asp.net solution. in class library, I have a method with following line: reader = XmlReader.Create(HttpContext.Current.Server .MapPath("~/TestDevice/Data.xml"), settings); When control comes to this line. I get exception. I tried to debug the code and found that when service tries to access this method then HttpContext.Current.Server is null . What is alternative syntax. I tried to access this class library method

what is the maximum time windows service wait to process stop request and how to request for additional time

别等时光非礼了梦想. 提交于 2019-12-17 16:09:44
问题 I have written a windows service in c# that process a lot data. when we stop it try for sometime 20/30 seconds and then throws exception. I want to implement ServiceBase.RequestAdditionalTime() in OnStop event. I want to know the exact timeout after which windows service throws the exception, so that I can request additional time just before it. I searched but did not find this default stop timeout value. 回答1: I wrote the following code to achieve it. protected override void OnStop() { int

What is the proper way for a Windows service to fail?

 ̄綄美尐妖づ 提交于 2019-12-17 15:42:37
问题 I have inherited a Windows service written in C#. Under rare conditions it fails badly. However, it isn't at all clear how to fail well. Ross Bennett states the problem elegantly at bytes.com. For the sake of simplicity I will just quote him here. Ahoy, Folks! I've been looking all over for this, but I just can't seem to shake any documentation out of the MSDN or from Google. I've reviewed every .NET article on developing Windows Services in the MSDN I've located. I'm developing a Windows

Setting a PHP script as a Windows Service

佐手、 提交于 2019-12-17 15:33:37
问题 I need to set up a PHP script as a windows service. I need it to run regardless of which user is logged in, and on system start up - so it sounds like a windows service is best, but am happy to hear other suggestions. (This script runs continuously, it's not a "run every 5 mins" thing I could use the Scheduled Task Manager for.) http://support.microsoft.com/kb/251192 covers using the sc.exe program to install your service. But from what I've read, I need to have a wrapper round the PHP script

Monitor when an exe is launched

纵饮孤独 提交于 2019-12-17 15:29:43
问题 I have some services that an application needs running in order for some of the app's features to work. I would like to enable the option to only start the external Windows services to initialize after the application is launched. (as opposed to having them start automatically with the machine and take up memory when the application is not needed) I do not have access to the exe's code to implement this, so ideally I would like to write a C# .Net Windows service that would monitor when an exe

Bulk Insert Sql Server millions of record

冷暖自知 提交于 2019-12-17 10:59:49
问题 I have a Windows Service application that receives a stream of data with the following format IDX|20120512|075659|00000002|3|AALI |Astra Agro Lestari Tbk. |0|ORDI_PREOPEN|12 |00000001550.00|00000001291.67|00001574745000|00001574745000|00500|XDS1BXO1| |00001574745000|›§ IDX|20120512|075659|00000022|3|ALMI |Alumindo Light Metal Industry Tbk. |0|ORDI |33 |00000001300.00|00000001300.00|00000308000000|00000308000000|00500|--U3---2| |00000308000000|õÄ This data comes in millions of rows and in

Running a Ruby Program as a Windows Service?

大憨熊 提交于 2019-12-17 10:14:21
问题 Is it possible to run a ruby application as a Windows Service? I see that there is a related question which discusses running a Java Application as a Windows Service, how can you do this with a Ruby application? 回答1: Check out the following library: Win32Utils. You can create a simple service that you can start/stop/restart at your leisure. I'm currently using it to manage a Mongrel instance for a Windows hosted Rails app and it works flawlessly. 回答2: When trying the Win32Utils one really

How do I change a Windows Service's startup type in .NET (post-install)?

无人久伴 提交于 2019-12-17 09:39:14
问题 I have a program that installs a service, and I'd like to be able to give the user the option later on to change the startup type to "Automatic". The OS is XP - if it makes any difference (Windows APIs?). How can I do this in .NET? C# if possible! :) 回答1: You can use the OpenService() and ChangeServiceConfig() native Win32 APIs for that purpose. I believe that there is some information on pinvoke.net and of course on MSDN. You might want to check out the P/Invoke Interopt Assistant. 回答2: I

How to send a custom command to a .NET windows Service from .NET code?

北慕城南 提交于 2019-12-17 08:21:33
问题 As in the following link, one can stop, start, and "stop, then start" a service using C# code. http://www.csharp-examples.net/restart-windows-service/ I have baked a .NET service that does implement OnStart and OnStop . However, I need to implement a "smart restart" functionality which is more involved than just stopping and then starting. I need to keep the downtime to just a few seconds if that (but Stop + Start can take minutes in this case when done cleanly, and I must do it cleanly), and

How to send a custom command to a .NET windows Service from .NET code?

ぐ巨炮叔叔 提交于 2019-12-17 08:21:15
问题 As in the following link, one can stop, start, and "stop, then start" a service using C# code. http://www.csharp-examples.net/restart-windows-service/ I have baked a .NET service that does implement OnStart and OnStop . However, I need to implement a "smart restart" functionality which is more involved than just stopping and then starting. I need to keep the downtime to just a few seconds if that (but Stop + Start can take minutes in this case when done cleanly, and I must do it cleanly), and