windows-services

How to make PostgreSQL trigger and C# Windows Service work together?

六月ゝ 毕业季﹏ 提交于 2019-12-08 05:28:33
问题 I want to write a windows service in C# that will wait for a change in the particular table in PostgreSQL database and then operate based on the data from the last inserted row. As far as I know (I'm new to PostgreSQL) I can use triggers to execute a function in structural code - but how to make it pass the data to my service? Thanks in advance for any suggestions. 回答1: Look at asynchronous notifications - http://www.postgresql.org/docs/8.4/static/sql-notify.html. Fire off a notification with

What is the best way to call/start a Windows Service every x seconds?

偶尔善良 提交于 2019-12-08 04:36:15
问题 I have a Windows Service which is basically accessing a mailbox and reading the emails. I am trying to figure out the best way to check the mailbox every x seconds. One method is to just call Thread.Sleep, then call the Start Method again, e.g. protected override void OnStart(string[] args) { // get config settings CheckMailbox(); } public void CheckMailbox() { int x = 5000; // do stuff Thread.Sleep(x); CheckMailbox(); } Not sure if this is the best way to go about it. To then further explore

how to start/stop windows services that have spaces in their names using c/c++

安稳与你 提交于 2019-12-08 04:29:58
问题 I am trying to write a c/c++ application that start/stop any windows service of my system. My application is working fine for services that have no spaces in between their name, but for service names that have space between them are not responding. Following are the commands i am using for opening service: SC_HANDLE serviceDbHandle = OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS); SC_HANDLE serviceHandle = OpenService(serviceDbHandle, "My Service", SC_MANAGER_ALL_ACCESS); Here "My Service" -

Help Understanding Impersonation

随声附和 提交于 2019-12-08 04:12:30
问题 I was looking for a way to Start / Stop Windows Services residing in a remote machine using C# code, and found the following code sample. It works fine for me. It is coded using Impersonation Technique, which apparently requires both the machines (let's say A and B) have a user account with the same UserName + Password combination. int LOGON32_LOGON_INTERACTIVE = 2; int LOGON32_PROVIDER_DEFAULT = 0; private bool impersonateValidUser(String userName, String machineName, String passWord) {

windows service run at exactly 11:59:59 PM

牧云@^-^@ 提交于 2019-12-08 04:03:07
问题 I am Writing a Windows service which will export reports to excel at user defined time. The User can choose to run report with following options: By Selecting StartTime and EndTime with DailyTime as the time to generate report Daily Report Weekly Report Monthly Report Yearly Report. Note( My SQL Server Data is Updated every second & I have written a Windows Application From which user will configure the above, which will be saved to xml) My windows service to configured to run at

resources on creating a windows service using c#

久未见 提交于 2019-12-08 04:00:00
问题 does anyone knows any good resources and articles that can explain how to create windows services using c#. thanks 回答1: I'd suggest you Google for the different parts, different places on the web have different information focus (and level of up-to date info). You need to know about these topics: Windows Service backgrounders: How services work in Windows. See how they are different in regards to user interface, system privileges (which account the service runs under, and what are its

Restart Windows Service in c#

前提是你 提交于 2019-12-08 03:26:27
I got a link from SO Cannot restart a Service where it says to restart the windows service. The way it should restart the service is mentioned in the question as public static void RestartService(string serviceName, int timeoutMilliseconds) { ServiceController service = new ServiceController(serviceName); int millisec1 = Environment.TickCount; TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds); if (!(service.Status.Equals(ServiceControllerStatus.Stopped) || service.Status.Equals(ServiceControllerStatus.StopPending))) { service.Stop(); service.WaitForStatus

VS 2008 Windows Service Installer Doesn't work

不打扰是莪最后的温柔 提交于 2019-12-08 03:13:46
问题 I just created a new windows service and I am having issues with the installer. I created the installer via this tutorial: http://www.sarin.mobi/2008/08/c-windows-service-visual-studio-2008/ Anyway, when I run the .msi generated by VS, the executable for this project is installed where I expect it to be. However, the service does not appear in Windows Services. When I use the VS command line tool and installutil, everything works just fine. I have created services in the past, so I compared

Windows service always writes to custom log and application log

穿精又带淫゛_ 提交于 2019-12-08 02:56:38
问题 I am using a custom EventLog for my Windows service. The service creates the event source after installtion. I don't have any problems. However, I have setup my service so that I can run it from the IDE using the following mechanism: static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException); string firstArgument = string.Empty; if (args.Length > 0) firstArgument = args[0].ToUpperInvariant(); if (string.Compare

Windows service locks up on assembly load

大兔子大兔子 提交于 2019-12-08 02:45:31
问题 I have a Windows Service written in C#. It includes a standalone console mode as well, for debugging purposes. It works fine on almost every computer it's been run on, but we ran into a situation where this service locks up when you try to start it, and then it gets killed because of timeout. But when running it in console mode on the same machine, it starts up fine. It's a pain to debug because I don't actually have access to the machine this is happening on, I have to go through a human