Windows Service for a long running task in .NET

Hi,

We have a working asp.net web application to which we are planning to add a new functionality.
This is a long running task which takes at least 30 minutes or more.
We are thinking a windows service may help us but we are not sure. I have a few questions as listed below


So, this is how it should work:

From the web application users will login and select a date, start time and end time and hit a submit button.
These 3 should be passed as parameters to the windows service.
Based on these 3 parameters, windows service will connect to the database and process the data and finally update the database.

Questions:

Can this be done in a windows service? Can we pass parameters to a windows service?
Within this windows service can we consume web services?
Right now, our web application and the database are on 2 different servers. Where should we install our windows service?

Thanks
shahjagatAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Can this be done in a windows service?
Yes.

Can we pass parameters to a windows service?
In a matter of speaking, yes. You will need some sort of inter-process communication (IPC).

Within this windows service can we consume web services?
Yes.

Where should we install our windows service?
Whichever you one you prefer, and which makes the most sense. Your service will be a process unto itself, so it should affect neither the web server software nor the database software--assuming you have a beefy machine. If you're still running single-core/single-processor machines, then it's going to be a hit no matter where you put it.

You might see better performance if the service is on the database machine since the database will be right there, but then you have to deal with sending parameters across the wire to the service. I believe remoting can handle this; not sure about named pipes--shared memory is definitely out. If you put the service on the web server, then any of the IPC should work, and the connection classes that you use to interact with databases are already set up to connect to remote systems.
0
shahjagatAuthor Commented:
kaufmed,

For this inter process communication, can i use WCF?
From WCF, how would i call the windows service?
0
käµfm³d 👽Commented:
Well that's kind of what I am saying:  In order to "call" the windows service, you will have to use some kind of inter-process communication. There is no way to call a remote application as if it were itself a function. You need to expose some mechanism for external processes to access your service. This is why I mentioned .NET remoting.

Now, if you instead wanted your service to call the WCF on some kind of timer, then that would be fairly straight-forward. You would simply "Add Service Reference" to your WCF service from within the Windows service project. Then you would simply need to set up a schedule for your Windows service to make the calls out to the WCF. You could use a timer for this scehduling.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shahjagatAuthor Commented:
kaufmed,

correct me if i am wrong.

The way i was thinking was
ASp.net web application calls a method exposed by WCF service which inturn will call a method in windows service.

ASP.NET --> WCF Service method ---> Windows Service

Can this be done?


Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.