0

I want a single thread of business process to run continuously in .net. For which can I am thinking of making a window service that will run continuously. If this service fails i want web based control for administrator.

Problem 1: If this service fails how can I check this through web based application(I can check by SC command using command prompt but how to move this to web based environment).

Problem 2: I m thinking of making service run continuously by using while(true) loop. Is this is correct way to address this problem.

Problem 3: How can I make sure only one instance run at time?

Cœur
  • 32,421
  • 21
  • 173
  • 232

2 Answers2

0

Problem 1: Why not just use exception handling to fire off an email, or write to an XML file that you could transform using XSLT

Problem 2: The service can run the application every 30 minutes. What do you mean by have the service run continuously what is the service for?

Problem 3: You can put check in the code to check if there is another instance running, see singleton pattern

Burt
  • 7,500
  • 18
  • 67
  • 121
  • hi burt my problem is i need to respond in quickest way possible. so i need to have something which will either monitor or listen and perform action within fraction of seconds so i am keeping it in continuous loop.. could you please tell me where can i look for singletone pattern as i must process files one after another as data in files is in incremental order... Thanks :) – Icarus Cool May 16 '12 at 17:10
0

Problem 1: see here

Problem 2: Not a great idea. What is the service doing? Usually it will fire on an event like a Filesystem Watcher, or sleep for a while and wake to perform necessary tasks.

Problem 3: A Windows service is not like other executables in that there will only be one copy of the service if you only install one. You start and stop it as required.

Community
  • 1
  • 1
CompanyDroneFromSector7G
  • 3,693
  • 12
  • 49
  • 88
  • hi bukko you solved my first problem. ya for second problem yes its watcher but its not file system watcher but database watcher. i want to read file as soon as its gets updated in database. but simillar time i dont want to process more than one file as data in files are in incremental order so what approach should i follow – Icarus Cool May 16 '12 at 17:05
  • Sounds like you either need a trigger in the database, or if it doesn't need to be instant, maybe a windows service based on a timer. Can your logic be built into the database? If not, are you using SQL Server? You could call a function in an assembly from the trigger maybe. – CompanyDroneFromSector7G May 16 '12 at 18:19
  • how can i ensure that only after processing first file i will go for another(as data is incremental)? if i update lock somewhere that i m currently reading some file and failed to update that lock in that case it will create problem... if i used timer i will have to make sure i finish my previous task within that time limit – Icarus Cool May 16 '12 at 19:05
  • By "file" I assume you mean "table". I would definitely use a trigger, probably a CLR trigger, which should give you all the control you need at both database and Windows levels. There's loads on the net about them, example [here](http://geekswithblogs.net/rajap/archive/2009/08/04/implementing-sql-clr-triggers.aspx). – CompanyDroneFromSector7G May 16 '12 at 19:20