windows-services

Stopping a multi-threaded windows service

﹥>﹥吖頭↗ 提交于 2019-12-07 02:46:16
问题 I have a multi-thread windows service in .Net 3.5, and I am having some trouble to stop the service properly when more than one thread is created. This service used to create only one thread to do all the work, and I just changed it to be multi-threaded. It works perfectly, but when the service is stopped, if more than one thread is being executed, it will hang the service until all the threads are completed. When the service is started, I create a background thread to handle the main process

Is a static object the same object in multiple running applications?

≡放荡痞女 提交于 2019-12-07 02:22:36
问题 If you have a windows service and a windows forms application that uses the same static object, is it the same object in both applications? In other words if I update the object in the service will it also be updated in the forms application as well if both are running at the same time? 回答1: They run on different processes so they don't share the static object. Not exaclty related with your question but threads created on the same application is a different story. They will share the static

Multiple threads in windows service

心已入冬 提交于 2019-12-07 02:21:29
I have windows project and one form which have timer for each 5 seconds. It calls and processes methods from request named table time wise and condition wise. But I have some methods types which takes too much time to respond and want those methods in separate thread. So that I can run those both request types in separate threads and syncs. How can I do separate those both using thread -- multi async threads? I recommend you look at the .NET 4.0 Task class. Firing full threads every time might be overkill. Tasks, together with timers use the underlying thread pool to execute work in parallel.

Manually implementing IoC with a Windows Service

此生再无相见时 提交于 2019-12-07 02:17:02
问题 I am brand new to IoC and thus have been following the examples provided by Jeffery Palermo in his posts at http://jeffreypalermo.com/blog/the-onion-architecture-part-1/ and in his book hosted here https://github.com/jeffreypalermo/mvc2inaction/tree/master/manuscript/Chapter23 Most important to note is that I am not using a pre-rolled IoC container, mostly because I want to understand all the moving parts. However, I am creating a windows service rather than an ASP.NET MVC webapp so I am

Get the version information of an installed service?

旧时模样 提交于 2019-12-07 02:10:44
问题 I want to check programmatically that the latest version of my Windows Service is installed. I have: var ctl = ServiceController.GetServices().Where(s => s.ServiceName == "MyService").FirstOrDefault(); if (ctl != null) { // now what? } I don't see anything on the ServiceController interface that will tell me the version number. How do I do it? 回答1: I am afraid there is no way other than getting the executable path from the registry as ServiceController does not provide that information. Here

Problem installing windows service

喜夏-厌秋 提交于 2019-12-07 01:24:48
问题 I am having a problem installing a Windows service. I installed and uninstalled the service numerous times (installutil..... installutil /u) without any problem but something went wrong and now when I attempt to install, I get the error message listed below. I checked the computer management console, and service CIMediator does not appear on the list of services. How do I remove the service? System.ArgumentException: Source CIMediator already exists on the local computer. 回答1: Just solved the

XCopy or MOVE do not work when a WCF Service runs a batch File. Why?

我的梦境 提交于 2019-12-07 00:54:12
问题 I have faced a case when the same batch file works differently from command line and when it is fired from a WCF service hosted on IIS. The difference is in XCOPY command. when I am running the batch file normally than XCOPY moves all data I need XCOPY "C:\from" "C:\to" /K /R /E /I /S /C /H /G /X /Y but when it runs from the WCF service nothing is copied. for running the batch from my service I am using the following code Executing Batch File in C# whith some little modifications. My

Task Handling on Application Shutdown

走远了吗. 提交于 2019-12-07 00:33:18
问题 I have a .Net (v4.0) Windows Service Application that spins of a tpl task at the beginning that performs certain, long running activities and basically stays alive for the application's life time and as such is created with the TaskCreationOptions. LongRunning parameter value. Whenever the service is stopped and the .OnStop() method is called, I .Cancel() the CancellationToken(Source) I handed over to the worker task when I created it and I want it's .OnlyOnCanceled(...) continuation task to

Windows Process Activation Service not starting - error 13

别说谁变了你拦得住时间么 提交于 2019-12-06 21:52:05
问题 I have IIS version 10 installed on Windows 10 Pro Version 1709, build 16299.125. After a Windows update, IIS stopped working. I saw that W3SVC isn't working, because WAS (Windows Process Activation Service) can't be started. When I try to start WAS, Windows display the message: Windows can't start Windows Process Aplication Service on Local Computer. Error 13: The data are invalid Looking at Windows Event Log, I see that WAS didn't started due event ID 5005, 5215 and Service Control Manager

Change Windows Service user programmatically

早过忘川 提交于 2019-12-06 21:16:04
问题 I need to change Logon user for a Windows service programmatically. And I am using the following code to do that: string objPath = string.Format("Win32_Service.Name='{0}'", ServiceName); using (ManagementObject service = new ManagementObject(new ManagementPath(objPath))) { object[] wmiParams = new object[11]; if (PredefinedAccount) { wmiParams[6] = "LocalSystem"; wmiParams[7] = ""; } else { wmiParams[6] = ServiceUsername; // provided by user wmiParams[7] = ServicePassword; // provided by user