Last post Aug 14, 2014 05:50 AM by developer6603
Feb 04, 2014 12:35 AM|developer6603|LINK
I have a windows service which is calling from an asp.net application. THis windows service will handle a long running process. So the user can log out and the windows service will hanlde the rest. So in windows service I have created a thread for doing
the background process. So once the thread finishes the task, do I need to call the service ‘stop’ event to make the service stop? (like this.stop() in code)
I didn’t clearly understand why it’s asking to not write code in ‘onstart’ event and asked to create a thread. Is it because the service will stop after a particular time? Will it cause my thread also to stop, when the service ends? Because I don’t need
that. The thread should handle a long running process; I need the thread not killed until it finishes the task.
Note:- its from a website the service is called , so any number of user can login to the website and call the service. So in each service call,a new thread will be created to handle each of this user request. Is that a better approach? will it affect performance?
Feb 07, 2014 06:24 AM|Ilikeit|LINK
This has been discussed as a part of other questions:
There is no good way to do this. You don't want any long running processes in the ASP.NET worker process, since it might recycle before you are done.
Write a Windows Service to run in the background that does the work for you. Drop messages into MSMQ to initiate tasks. Then they can run as long as they want.
Aug 14, 2014 05:50 AM|developer6603|LINK
Thanks for the reply. Can I do the same using WCF and MSMQ? Otherwise my windows service need to continuously monitor MSMQ and if 100 users send request , all will be in waiting stage. If it is WCF service, when the request come I can call the WCF service
and take the first MSMQ request. then for next request another call to WCF service and take the task in MSMQ. Is that a good approach?