windows-services

Programmatically limit CPU Usage of a Thread running inside a Service

半世苍凉 提交于 2019-11-27 16:34:14
问题 I'm using VB9 (VS2008). I've created a Windows Service that indexes some folders regularly. Is there a way I can put an upper limit on the CPU usage depending upon the current system state, i.e., if the system is idle, the thread can use the CPU as much as it needs, but if there are other programs/processes running then it should use the CPU in way that does not make the system slow. 回答1: You can reduce the priority of the thread, in .Net via Thread.Priority Setting it to BelowNormal will

Basic design pattern for using TPL inside windows service for C#

守給你的承諾、 提交于 2019-11-27 16:33:43
问题 I am trying to build up windows service which need some kind of parallelism for pooling files from different ftp sources. For starting multiple ftp downloads I am looking in TPL library to easily do foreach loops and making parallelism totally easy. But when I search how to start or stop my service(s), best shot I fund is to make new threads inside OnStart() method, as it is described here https://stackoverflow.com/a/4865893/69433 Reading about TPL there is always note that TPL is more

Installing a Windows Service with dependencies

為{幸葍}努か 提交于 2019-11-27 15:55:00
问题 My installer program doesn't suppport installing services but I can run a program/command line etc so my question is how can I install a Windows Service and add 2 dependencies using the command line? The program is a .Net 2.0 app. Thanks 回答1: You can write a self-installing service and have it set a list of services your service depends on when the installer is executed. Basic steps: Add a reference to System.Configuration.Install to your project. Add a class that derives from System

Why won't my windows service write to my log file?

本小妞迷上赌 提交于 2019-11-27 15:51:28
问题 I have a windows service and use nlog for logging. Everything works fine when I run from the visual studio ide. The log file updates with no issues. When I install the service, the service runs fine but the log file never updates. I am running under LOCAL SERVICE if that helps. Yes, I have created the logs directory under my application folder. <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema

Calling System.exit() in Servlet's destroy() method

我们两清 提交于 2019-11-27 15:18:44
问题 This is a follow up to my earlier question. Tomcat 5.0.28 had a bug where the Servlet's destroy() method was not being invoked by the container on a shutdown. This is fixed in Tomcat 5.0.30, but if the Servlet's destroy() method had a System.exit(), it would result in the Tomcat windows service throwing the Error 1053 and refusing to shutdown gracefully (see above link for more details on this error) Anybody has any idea on whether: Calling System.exit() inside a Servlet's destroy() method to

Needed: A Windows Service That Executes Jobs from a Job Queue in a DB; Wanted: Example Code

最后都变了- 提交于 2019-11-27 15:16:58
Needed: A Windows Service That Executes Jobs from a Job Queue in a DB Wanted: Example Code, Guidance, or Best Practices for this type of Application Background: A user will click on an ashx link that will insert a row into the DB. I need my windows service to periodically poll for rows in this table, and it should execute a unit of work for each row. Emphasis: This isn't completely new terrain for me. EDIT: You can assume that I know how to create a Windows Service and basic data access. But I need to write this service from scratch. And I'd just like to know upfront what I need to consider.

Killing EXCEL.exe Process from C# in a Windows Service

我怕爱的太早我们不能终老 提交于 2019-11-27 15:16:49
问题 I have a windows service that opens up an Excel spreadsheet via the Microsoft.Office.Interop.Excel.Application object. Application xlApp = new Application(); Workbook workbook = xlApp.Workbooks.Open(fileName, 2, false); ... ... workbook.Close(); xlApp.Quit(); I would like to kill the EXCEL.exe process that is left running after it is done working with the workbook. I've tried the following with no success... // This returns a processId of 0 IntPtr processId; GetWindowThreadProcessId(new

Install java program as a windows service: Alternative to JavaService? [closed]

隐身守侯 提交于 2019-11-27 15:02:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'd like to install a Java application as a Windows service. I did so successfully a couple of years ago using this Java Service wrapper. Unfortunately, it seems like this tool is not in development anymore and thus no Windows 7 and 64 bit versions are available. I need to install my Java application on Windows

Play wave file from a Windows Service (C#)

点点圈 提交于 2019-11-27 14:52:48
I need to play a wav file from a C# application running as a Windows Service. I have tried both System.Media.SoundPlayer and a P/Invoke call to WinMM.dll (which is probably what SoundPlayer is doing). [DllImport("WinMM.dll")] private static extern bool PlaySound(string fname, int Mod, int flag); If I run my code as a console application, the sounds play. When I run it from a service, no luck, and I guess I'm not surprised. So is there a way to play a sound from a windows service? Would something like DirectSound help? Or am I going to be stuck writing a console application and having the

I want my C# Windows Service to automatically update itself

纵然是瞬间 提交于 2019-11-27 14:23:40
问题 Is there a framework that can be used to enable a C# Windows Service to automatically check for a newer version and upgrade itself? I can certainly write code to accomplish this, but I am looking for a framework that has already been implemented and (most importantly) tested. [edit] Here is a link to a similar question with links to modern projects that help accomplish this: Auto-update library for .NET? 回答1: The only way to unload types is to destroy the appdomain. To do this would require