windows-services

How to call Webservice from Windows Service?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 15:55:36
How to call Webservice from Windows Service? I am having one webservice on my Webserver. I have a windows-service to trigger that webservice. So I just want to integrate and call my webservice from my windows service. How can I do that? EDIT: TempWindowService is name of my windows application MyServ is the name of my reference of my webservice. TempWindowService.MyServ newService = new TempWindowService.MyServ(); newService.BatchProcess(); Here BatchProcess() is the webmethod under my webservice. I get error on line TempWindowService.MyServ newService = new TempWindowService.MyServ(); Error

How can I accomplish ThreadPool.Join?

浪子不回头ぞ 提交于 2019-11-30 15:54:40
问题 I am writing a windows service that uses ThreadPool.QueueUserWorkItem() . Each thread is a short-lived task. When the service is stopped, I need to make sure that all the threads that are currently executing complete. Is there some way of waiting until the queue clears itself? 回答1: You could create an event (e.g. ManualResetEvent ) in each thread, and keep it in a synchronised list (using the lock construct). Set the event or remove it from the list when the task is finished. When you want to

How can I configure my windows service in the code to access the desktop?

风格不统一 提交于 2019-11-30 15:45:15
I have created an windows service. I want to open some windows based application from this service. But my windows service is unable to start desktop applications. To enable the access I had to do the following steps: Opened the administrative tool "Services" Right clicked on my service and had to select "properties" Then in the "Log On" tab, selected "Allow service to interact with desktop". After that my service can open desired windows based processes. Can I configure my windows service in the code (C#) to access the desktop so that I won't have to change the access permission manually

Consuming a WCF Service that is hosted in a Windows Service from outside solution

拟墨画扇 提交于 2019-11-30 15:14:34
I've set up a WCF Library hosted in a Windows Service using the following walk-through: http://msdn.microsoft.com/en-us/library/ff649818.aspx The consumer winforms is in the same solution, which is located locally on my work PC's C: drive. The walk-through works i.e. the winforms button gives me the correct answer. If I create a new Solution on the C-Drive with a single Windows Forms project in it I cannot successfully add a service reference to this running service, i get the following message: The detailed message says the following: The URI prefix is not recognized. Metadata contains a

Using a FileSystemWatcher with Windows Service

a 夏天 提交于 2019-11-30 14:49:56
I have a windows service which needs to monitor a directory for files and then move it to another directory. I am using a FileSystemWatcher to implement this. This is my main Service class. public partial class SqlProcessService : ServiceBase { public SqlProcessService() { InitializeComponent(); } protected override void OnStart(string[] args) { FileProcesser fp = new FileProcesser(ConfigurationManager.AppSettings["FromPath"]); fp.Watch(); } protected override void OnStop() { } } This is my FileProcessor Class public class FileProcesser { FileSystemWatcher watcher; string directoryToWatch;

How to configure Hudson and git plugin with an SSH key

∥☆過路亽.° 提交于 2019-11-30 14:42:08
问题 I've got Hudson (continuous integration system) with the git plugin running on a Tomcat Windows Service. msysgit is installed and the msysgit bin dir is in the path. PuTTY/Pageant/plink are installed and msysgit is configured to use them. When I run a job that attempts to clone the git repository I get the following error: $ git clone -o origin git@hostname:project.git "e:\HUDSON_HOME\jobs\Project Trunk\workspace" ERROR: Error cloning remote repo 'origin' : Could not clone git@hostname

How can I accomplish ThreadPool.Join?

梦想的初衷 提交于 2019-11-30 14:40:34
I am writing a windows service that uses ThreadPool.QueueUserWorkItem() . Each thread is a short-lived task. When the service is stopped, I need to make sure that all the threads that are currently executing complete. Is there some way of waiting until the queue clears itself? You could create an event (e.g. ManualResetEvent ) in each thread, and keep it in a synchronised list (using the lock construct). Set the event or remove it from the list when the task is finished. When you want to join, you can use WaitHandle.WaitAll ( MSDN documentation ) to wait for all the events to be signalled. It

Can a Windows service stop itself?

亡梦爱人 提交于 2019-11-30 14:39:03
问题 I have a Windows service whose startup type is automatic, but I want to do some checks when the service starts, and have the service stop automatically if these checks fail. How can I do this? My service is written in C#. 回答1: You can call the Stop method on your ServiceBase class. See msdn for more details. 回答2: You can use ServiceController and call .stop. ServiceController sc= new ServiceController(service); sc.Stop(); 来源: https://stackoverflow.com/questions/11770206/can-a-windows-service

Windows service installer not reading App.Config file

℡╲_俬逩灬. 提交于 2019-11-30 14:33:58
I have added App.Config in my project. I have a installer class(ProjectInstaller.cs) which needs to read values from App.config. I am providing the keys . Below is the sample Code : ConfigurationManager.AppSettings["CONFIG_FILE"] I am getting null values as per above code ,when invoked in Installer class. But in App.Config file the value for the above key exists. Try: public string GetServiceNameAppConfig(string serviceName) { var config = ConfigurationManager.OpenExeConfiguration(Assembly.GetAssembly(typeof(MyServiceInstaller)).Location); return config.AppSettings.Settings[serviceName].Value;

TService won’t process messages

十年热恋 提交于 2019-11-30 14:26:35
问题 I have created a windows service that uses Windows Messaging System. When I test the app from the debugger the Messages go through nicely but when I install it my messag … asked 14 mins ago vladimir 1tuga 回答1: Services don't generally receive window messages. They don't necessarily have window handles at all. Even if they do, they run in a separate desktop. Programs cannot send messages from one desktop to another, so a service can only receive messages from another service, or from a program