windows-services

how to have a function run inside a service every 10 minutes?

两盒软妹~` 提交于 2019-12-02 18:37:23
I have a windows service running, inside this i want to run a function every then minutes. I have found some code but it doesn't seem to work? I have a logger and it does not seem to go into the timer_Elapsed function ever? protected override void OnStart(string[] args) { // SmartImportService.WebService.WebServiceSoapClient test = new WebService.WebServiceSoapClient(); // test.Import(); log.Info("Info - Service Started"); _timer = new Timer(10 * 60 * 1000); // every 10 minutes?? _timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); } private void timer_Elapsed(object sender,

Thread Sleep and Windows Services

倖福魔咒の 提交于 2019-12-02 18:37:01
I'm working on a Windows Service that's having some issues with Thread.Sleep() so I figured I would try to use a timer instead as this question recommends: Using Thread.Sleep() in a Windows Service Thing is it's not entirely clear to me how one might implement this. I believe this is the way but I just wanted to make sure: '' Inside The Service Object Dim closingGate As System.Threading.AutoResetEvent Protected Overrides Sub OnStart(ByVal args() As String) Dim worker As New Threading.Thread(AddressOf Work) worker.Start() End Sub Protected Sub Work() Dim Program = New MyProgram() closingGate =

Pros and Cons of running Quartz.NET embedded or as a windows service

有些话、适合烂在心里 提交于 2019-12-02 18:22:49
I want to add quartz scheduling to an ASP.NET application. It will be used to send queued up emails. What are the pros and cons of running quartz.net as windows service vs embedded. My main concern is how Quartz.NET in embedded mode handles variable number of worker processes in IIS. Here are some things to you can consider while you decide whether you should run embedded or not: If you are going to be creating jobs ONLY from within the hosting application, then run embedded. Otherwise, run as a service. If your jobs might need permissions that are different from the permissions that the web

What is the most reliable way to create a custom event log and event source during the installation of a .Net Service

孤街浪徒 提交于 2019-12-02 18:06:24
I am having difficulty reliably creating / removing event sources during the installation of my .Net Windows Service. Here is the code from my ProjectInstaller class: // Create Process Installer ServiceProcessInstaller spi = new ServiceProcessInstaller(); spi.Account = ServiceAccount.LocalSystem; // Create Service ServiceInstaller si = new ServiceInstaller(); si.ServiceName = Facade.GetServiceName(); si.Description = "Processes ..."; si.DisplayName = "Auto Checkout"; si.StartType = ServiceStartMode.Automatic; // Remove Event Source if already there if (EventLog.SourceExists("AutoCheckout"))

Installing a Topshelf application as a Windows service

半城伤御伤魂 提交于 2019-12-02 17:49:46
Using Visual Studio Express 2012, I've created a console application using Topshelf (Version 3.1.107.0). The application works as a console application, but I can't figure out how to install it as a service. I've published the project from within Visual Studio (Build, Publish), started a command prompt as Administrator, navigated to the folder where the application was published, and run setup.exe -install from the command prompt. The application is installed and runs, but as a console application, not a Windows service. What am I missing here? For those who may not be familiar with Topshelf,

Check if no user is currently logged on to Windows

半世苍凉 提交于 2019-12-02 17:41:53
I'm writing a Windows Service application which listens for connections and performs certain tasks as instructed from a different application running on another computer on the network. One of the tasks ensures no user is currently logged on, locks the workstation, delete some files, and then restarts the system. I considered using this solution to look through the list of running processes and check the user names, determining if no user is logged on by matchhing the user names against SYSTEM, NETWORK, etc. I realized I have PostgreSQL running which uses a user account named postgres so that

C# Windows Service

坚强是说给别人听的谎言 提交于 2019-12-02 17:32:19
问题 Scenario I've created a windows service, but whenever I start it, it stops immediately. The service was concieved from a console application that used to subscribe to an event and watch processes on a server. If anything happened to process (i.e. It was killed), then the event would trigger the process to be restarted. The reason I'm telling you this is because the original code used to look like this: Original Console App Code: static void Main(string[] args) { StartProcess sp = new

How can I install a windows service onto a machine that doesn't have Visual Studio installed?

房东的猫 提交于 2019-12-02 17:31:23
The only way to install windows-service I know is using " Visual Studio 2008 Command Prompt ", Is there a way to install windows-service on a machine which isn't having Visual Studio installed (assume that .Net version 2.X is installed.) you can do it with installUtil which resides in the .net framework folder (on my machine it's C:\Windows\Microsoft.NET\Framework\v2.0.50727). Ivan Dormain You can install Windows Services as an MSI. Create the MSI as a normal Project attached to your Service Project. In your Service Project Create an Installer Class and add the components serviceInstaller and

running Elastic Search as a Windows service

若如初见. 提交于 2019-12-02 16:39:36
Is there a way to run Elastic Search as a Windows service? It may not be possible, but I thought I would see. As of 0.90.5+, support for running ElasticSearch as a Windows Service is officially included in the Windows distribution. http://www.elasticsearch.org/blog/0-90-5-released/ From the bin folder: > service.bat Usage: service.bat install|remove|start|stop|manager [SERVICE_ID] > service install Installing service : 'elasticsearch-service-x64' Using JAVA_HOME (64-bit): c:jvmjdk1.7 The service 'elasticsearch-service-x64' has been installed. > service start The service 'elasticsearch-service

How does a Windows service differ from a standard exe?

ぐ巨炮叔叔 提交于 2019-12-02 16:33:58
What's the difference between a Windows service and a standard exe? A windows service always runs once the computer starts up (as long as it's so configured). A standard EXE only runs when a user is logged in, and will stop if the user logs out. You would use a windows service for things that always need to run even if nobody is logged in. You would use a standard EXE for programs that a user will run while logged in. A Windows service has a special ServiceMain function and must respond to Service Control Manager (SCM) commands properly in order to be functional as a service. On the other hand