Mohamed ElSheikh
asked on
What is the equivalent of a Windows service web in C#?
Hello
i am wondering, how can i create something like Windows service on ASP.Net MVC to Triger and run tasks based on a database
suppose i have a workflow engine in database, i want to create a trigger that keep looking all the time for a new record added into SQL Server table, then run the added task.
tasks can be something like connect tosql table and export data, rename file, zip file, send email notification ...,etc.
can we also limit the number of multithreading or parallels tasks to preidentified number
please show me a samples
Thanks
i am wondering, how can i create something like Windows service on ASP.Net MVC to Triger and run tasks based on a database
suppose i have a workflow engine in database, i want to create a trigger that keep looking all the time for a new record added into SQL Server table, then run the added task.
tasks can be something like connect tosql table and export data, rename file, zip file, send email notification ...,etc.
can we also limit the number of multithreading or parallels tasks to preidentified number
please show me a samples
Thanks
ASKER
Thank you Peter for your response
It is not that simple, and not all tasks based on inserting new record.
In some task, we need to apply some logics which they are not available in database, for example, one task can convert a file from one type to other type, one compares two files, zip files, send emails, print file, export data from different data sources, shared folders and so on, and SQL table trigger can not do most of them.
In addition table trigger is slowing the table operations
my thought is creating a workflow engine user, assign some tasks to that user when we design the work flow to automatically run these steps using that subject service, when we add a new instance "order" that service will look to the workflow design table, check the current step, perform that step task if it is assigned to that user
thank you again
It is not that simple, and not all tasks based on inserting new record.
In some task, we need to apply some logics which they are not available in database, for example, one task can convert a file from one type to other type, one compares two files, zip files, send emails, print file, export data from different data sources, shared folders and so on, and SQL table trigger can not do most of them.
In addition table trigger is slowing the table operations
my thought is creating a workflow engine user, assign some tasks to that user when we design the work flow to automatically run these steps using that subject service, when we add a new instance "order" that service will look to the workflow design table, check the current step, perform that step task if it is assigned to that user
thank you again
Hi,
For this, you can create scheduled job (to be implemented periodically) on your Windows server. Such job can definitely check values of table rows of the database, and to trigger relevant process like what you mentioned, within the server.
For this, you can create scheduled job (to be implemented periodically) on your Windows server. Such job can definitely check values of table rows of the database, and to trigger relevant process like what you mentioned, within the server.
I don't know what version of .NET you are using, but you are probably looking for a Hosted Service which can run in the background and poll your queue for tasks. The link above includes a basic example with a timer, you can implement this to poll your queue and process the tasks at each interval.
To limit the total running tasks at once you can just track how many are running in a variable and if the max limit is hit the timer just sleeps until a slot opens up.
There's no harm in having a separate Windows service running on a server that also polls the database though if you aren't able to implement a hosted service.
To limit the total running tasks at once you can just track how many are running in a variable and if the max limit is hit the timer just sleeps until a slot opens up.
There's no harm in having a separate Windows service running on a server that also polls the database though if you aren't able to implement a hosted service.
ASKER
Thank you Dustin
I've .Net Framework not Core, but i will check with IT if we can have it installed.
do we have a similar Hosted Service under .Net Framework nor core?
I agree with you, Windows service was my preferred solution, but we are not allowed to use Win Service.
I am not sure if the Hosted Service -your solution- need to install a Windows Services behind the scene or not
thank you again for your help
I've .Net Framework not Core, but i will check with IT if we can have it installed.
do we have a similar Hosted Service under .Net Framework nor core?
I agree with you, Windows service was my preferred solution, but we are not allowed to use Win Service.
I am not sure if the Hosted Service -your solution- need to install a Windows Services behind the scene or not
thank you again for your help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
If you expect things to be done when new records are created on specific table, you can create table trigger to perform any expected job or action, once record has been inserted into table.