windows-services

TCP IP Listener in windows Service

三世轮回 提交于 2019-12-04 15:49: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); }

NotifyFilter of FileSystemWatcher not working

百般思念 提交于 2019-12-04 15:40:31
I have a windows service (and verified the code by creating a similar WinForms application) where the NotifyFilter doesn't work. As soon as I remove that line of code, the service works fine and I can see the event-handler fire in the WinForms application. All I'm doing is dropping a text file into the input directory for the FileSystemWatcher to kick off the watcher_FileChanged delegate. When I have the _watcher.NotifyFilter = NotifyFilters.CreationTime; in there, it doesn't work. When I pull it out, it works fine. Can anyone tell me if I'm doing something wrong with this filter? Here is the

Difference between ThreadPool.QueueUserWorkItem and Parallel.ForEach?

随声附和 提交于 2019-12-04 15:37:33
问题 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

Windowservice error

柔情痞子 提交于 2019-12-04 14:54:00
问题 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

How to determine the current windows user from a windows service?

自作多情 提交于 2019-12-04 14:40:57
问题 I'm writing a Windows Service using C# .NET 2005. How can I determine who the currently logged-on user is (if any)? Also is there a way to be notified when a user logs on? Alternatively, is there a way to know who has recently used the machine? I need to know the currently logged on user so I can cache some data for that user. Operating in a corporate environment there are thousands of potential users but it only makes sense to cache data for someone who uses that machine. UPDATE: This

Max TCP Connections to a machine

回眸只為那壹抹淺笑 提交于 2019-12-04 14:30:56
问题 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

Close foreground thread gracefully on windows service stop

给你一囗甜甜゛ 提交于 2019-12-04 14:10:31
In my windows service I create one "parent" foreground thread that in turn spawns "child" threads using ThreadPool (which means they are background) to execute tasks. What is the best way to close foreground thread gracefully on windows service stop? Here is my current implementation (stripped out of task-specific logic): public partial class TaskScheduler : ServiceBase { private static AutoResetEvent _finishedTaskAutoResetEvent = new AutoResetEvent(false); //This flag is used to increase chances of the Spawning Thread to finish gracefully when service stops. private bool StopRequested { get;

C# based Windows Service - Tries to do JIT Debugging in production

坚强是说给别人听的谎言 提交于 2019-12-04 14:09:46
I am getting this error in my event logs for a service I put into production: An unhandled win32 exception occurred in RivWorks.FeedHandler.exe [5496]. Just-In-Time debugging this exception failed with the following error: Debugger could not be started because no user is logged on. I have it installed and running under a Win NT global account. I have no idea why it is trying to drop into debugging mode. It was built under the Release model. Running on the 4.0 Framework. When I run on my dev machine, via an EXE entry point instead of the WinSvc entry point, everything runs just fine - BUT - I

C# Query Windows Service

南笙酒味 提交于 2019-12-04 13:46:36
I have been using an application that queries Windows Services running on remote servers and writes the Machine Name, Service Name, and Status to a database. However, I want to try and capture the startup type (Automatic, Manual, Disabled) as well. I was using a Service Controller which does not have any options for startup type so I started looking at using a Management Class. This class looks like it has everything I need but I don't know how to use it against my remotes servers. For the Service Controller, I was doing this: ServiceController[] services = ServiceController.GetServices

How can I find the process id from the service name/handle in Delphi?

时间秒杀一切 提交于 2019-12-04 13:38:25
问题 I have the service name for a windows service in delphi, and I know how to get the handle from that as well. What I need to do is stop a service, and if the stop fails for some reason I need to kill the process associated with the service. The problem is that I have multiple services running from the same executable, so I can't use the executable name to kill the process. This means I need the process id to kill the proper associated process. How can I get this id or some way to kill the