windows-services

How can I send MailMessages using multiple threads?

不羁岁月 提交于 2019-12-18 12:41:13
问题 I hope you guys will bear with me for my total lack of direction in case of Threading. I have to implement a Mail Queue Processing System where I have to send emails queued up in a database through a Windows Service. It is not a producer-consumer pattern. I have fetched say 10 rows at a time into a datable. The datatable contains the serialized MailMessage object and SMTP sending details. If I have to use say a fixed number of threads (say 6 threads) Now how would I go about fetching a row

Can you host multiple WCF processes in a single windows service?

谁说我不能喝 提交于 2019-12-18 12:38:56
问题 I have a WCF process hosted in a windows service. I am wondering if I can safely have multiple WCF processes that do different things hosted in the same windows service. Do I have to worry about ports? I am using a mex endpoint 回答1: Yes, you can. I am doing this exact thing in my project, hosting three separate WCF services inside my Windows service. Just make sure that each WCF endpoint, i.e., the address/binding/contract tuple, is unique. 回答2: EDIT: SO seems to be trimming my lengthy code

System.Timers.Timer How to get the time remaining until Elapse

安稳与你 提交于 2019-12-18 11:53:01
问题 Using C#, how may I get the time remaining (before the elapse event will occur) from a System.Timers.Timer object? In other words, let say I set the timer interval to 6 hours, but 3 hours later, I want to know how much time is remaining. How would I get the timer object to reveal this time remaining? 回答1: The built-in timer doesn't provide the time remaining until elapse. You'll need to create your own class which wraps a timer and exposes this info. Something like this should work. public

Scheduled console app vs Windows service? When is it appropriate to use each

北城以北 提交于 2019-12-18 11:11:23
问题 I just read this: What is the benefit of developing the application as a windows service? but I'm still unsure of when to use a windows service. I have a couple tasks that need to be run at intervals (i.e. every 5 minutes). Which project type should I use? Are there any examples of the types of applications that should be Windows services? 回答1: For any scheduled task, I would usually recommend a Windows Service, for the following reasons: A Windows Service will run even if a user is not

Using InstallUtil and silently setting a windows service logon username/password

你离开我真会死。 提交于 2019-12-18 10:02:52
问题 I need to use InstallUtil to install a C# windows service. I need to set the service logon credentials (username and password). All of this needs to be done silently. Is there are way to do something like this: installutil.exe myservice.exe /customarg1=username /customarg2=password 回答1: A much easier way than the posts above and with no extra code in your installer is to use the following: installUtil.exe /username=domain\username /password=password /unattended C:\My.exe Just ensure the

Any way to override .NET Windows Service Name without recompiling?

醉酒当歌 提交于 2019-12-18 09:59:50
问题 I have a windows service executable that I know is written in .NET which I need to install under a different service name to avoid a conflict. The install doesn't provide anyway to specify a service name. If I only have access to the binary, is there anyway to override the service name when I install it with installutil? 回答1: Do you have to use InstallUtil? Here are the commands to do what you want using sc: sc create MyService binPath= "MyService.exe" DisplayName= "MyService" sc description

How to force uninstallation of windows service

ⅰ亾dé卋堺 提交于 2019-12-18 09:57:24
问题 I installed a windows service using installUtil.exe. After updating the code I used installUtil.exe again to install the service w/o uninstalling the original version first. When I now try to uninstall the service, installUtil.exe completes the uninstall successfully, but the service still appears. If I try to change its properties, I receive the message 'service is marked for deletion'. How can I force the deletion (preferrably w/o restarting the server)? 回答1: One thing that has caught me

Cannot restart a Service

此生再无相见时 提交于 2019-12-18 09:53:31
问题 I have this code to restart a service, but this is not working. I can start and stop individually but not restart which involves me to first stop and start the service. try { //service.Stop(); //service.Start(); int millisec1 = Environment.TickCount; TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds); service.Stop(); service.WaitForStatus(ServiceControllerStatus.Stopped, timeout); // count the rest of the timeout int millisec2 = Environment.TickCount; timeout = TimeSpan

c# windows service

泄露秘密 提交于 2019-12-18 09:47:27
问题 I have a running windows service. I would like to monitor a c# console application from the windows service . My c# console application reads and writes in the console a sum, multiplication. I would like to open and work with my console application using my windows service . What should i write in OnStart() method in order to execute properly my c# code. I did put in windows service the exe file (Process.start()) from my console application code but i have the error: console application

Wix Service Installer sometimes fails to install or start

五迷三道 提交于 2019-12-18 09:28:20
问题 Sometimes when i am running my installer (build with wix) it fails to install or start the service. But the problem doesn't always appear, so most of the time it works and but now and then it fails. My solutions until now are: Retrying by pressing the retry button. Retrying by closing the installer and opening it again. Retrying by closing the installer and the windows file explorer and the reopening both. Disconnecting external drive and the reconnecting it and retrying the installer. But i