windows-services

Difference between ThreadPool.QueueUserWorkItem and Parallel.ForEach?

雨燕双飞 提交于 2019-12-03 09:43:44
What is the main difference between two of following approaches: ThreadPool.QueueUserWorkItem Clients objClient = new Clients(); List<Clients> objClientList = Clients.GetClientList(); foreach (var list in objClientList) { ThreadPool.QueueUserWorkItem(new WaitCallback(SendFilesToClient), list); } System.Threading.Tasks.Parallel ForEach Clients objClient = new Clients(); List<Clients> objClientList = Clients.GetClientList(); Parallel.ForEach<Clients>(objClientList, list => { SendFilesToClient(list); }); I am new to multi-threading and want to know what's going to happen in each case (in terms of

Singleton or not

佐手、 提交于 2019-12-03 09:41:06
问题 I have a windows service running.Inside this service I have hosted some service (WCF). I need to have some kind of a "in memory data holder" class. The purpose of this class is to hold not-persistant data as long as the windows service is running. This class must be accessible thru the WCF services. They put some values in this class or retrieve some values from this class. First thing what come across my mind was a singleton class.I think this pattern fits perfect for this situation. But

Getting a Service to Run Inside of an Azure Worker Role

做~自己de王妃 提交于 2019-12-03 09:32:16
问题 I have a windows service that I need to migrate to onto Azure as a Worker Role. Everything builds fine in my Azure solution. However, when I upload everything only the web role starts. The worker role instance gets stuck cycling between the following two statuses without ever starting. Waiting for the role to start... Stabilizing role... Since the instance is failing to start I suspect my problem lies somewhere in my WorkerRole.cs code. Below you'll find that code. I've also included the code

How to get name of windows service from inside the service itself

北城以北 提交于 2019-12-03 09:27:28
问题 I have a bunch of win services written in .NET that use same exact executable with different configs. All services write to the same log file. However since I use the same .exe the service doesn't know its own service name to put in the log file. Is there a way my service can programatically retrieve its own name? 回答1: Insight can be gained by looking at how Microsoft does this for the SQL Server service. In the Services control panel, we see: Service name: MSSQLServer Path to executable: "C:

How do I change the name of my Windows service?

删除回忆录丶 提交于 2019-12-03 09:22:54
I have a Windows Service and want to change the name of it (as it appears in the Services application). But I'm unsure of the correct way to do so. It appears to be the ServiceName property and searching through my solution I found this: namespace SI.AService.AService { partial class AService { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected

Windowservice error

淺唱寂寞╮ 提交于 2019-12-03 09:14:52
I have solution which contain so many projects and windowservices. I modified coding on the application side of windowservice,after that i copied the exe regarding that service(F:\Components\Console\Bin\service.exe) in to the installation path(C:\Program Files\syscon\ Monitor\service.exe) after stopping windowservice from the 'services.msc'.Now i am getting the value on service while debugging which is not getting previously.But now when i start the service from 'services.msc' i am getting this error "Could not start the operational sentinel windows resource monitor service on local computer

Max TCP Connections to a machine

∥☆過路亽.° 提交于 2019-12-03 09:05:52
I am creating a Windows Service in .NET to which N number of client can connect. The service starts a TCP listener and accepts the client connections. The problem I am facing is that I can only open 10 connections to this service. The listener::AcceptTcpClient() method accepts only 10 connection and throws an exception for 11th one. The client application uses the System.Net.Sockets.TcpClient class and the service is using System.Net.Sockets.TcpListener class. This is the exception that I am getting when I try to make a number of connections in a for loop to this service (after the 10th

Adding a service installer and service process installer in visual studio

梦想的初衷 提交于 2019-12-03 09:04:10
问题 For some reason, after adding a Installer class to my Windows Service project, I open it up in design mode and right click, but there is no option to add either a service installer or a service process installer. Does anyone know why this may be the case? 回答1: In both Visual Studio 2008 and 2010, the best way to do this is to open the ServiceBase component (named Service1 by default) in design mode. Then, right-click in the designer and select the Add Installer option. This adds a

TCP IP Listener in windows Service

房东的猫 提交于 2019-12-03 08:57:44
I'm trying to create a windows service that needs to run in the background and listen for incoming traffic (a normal and regular TCP listener) my code is: private TcpListener server; public void startServer() { // EventLog.WriteEntry(source, "connected on: " + ipAddress.ToString() + " port: " + Service1.Port.ToString()); server = new TcpListener(IPAddress.Parse("127.0.0.1"), Service1.Port); server.Start(); while (true) { var client = server.AcceptTcpClient(); new Thread(work).Start(client); } public void work(object client) { string msg = null; var clientLocal = (TcpClient)client; using

How to make HTTP request in windows service? [closed]

两盒软妹~` 提交于 2019-12-03 08:46:48
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center . i want to implement my first windows service application. this app must run day and night. it should to send each 1 hour http request with possibility to make snapshot of requested webpage and save it in database. can you show me some c# code examples how to: make http request from windows service. set a timer for requesting each 1