简体   繁体   中英

background thread in asp.net application

i run a background thread in Application_Start() in global.asax to use it like windows service but applicaton_end fire when all session is ended in my website

i have a sms Business that work with webservice and i want to have agent in my server that check incoming message like windows service

i increase session timeout to 10 hours but when i close browser application end fired and my thread stop working

i cant change server properties

can i disable application_end to thread keep working?

I apologize to you because of poor english writing

You should make a separate program that runs as a service or a batch program to do that. Although ASP.NET persists static variables and such between page loads, you shouldn't be using it to run things in the background. There is no guarantee that things will keep running.

If you need something to happen on the user's end when something happens on the server (like a message received (like on facebook), someone responds to a request, or some other event is raised) you need to implement a polling system in javascript on the webpage that the user sees which uses AJAX (look it up...its such an awesome concept) to periodically talk to the server to see if anything happened. That is how Facebook chat works along with most webmail systems to check for new messages. The server doesn't talk to the browser...the browser asks the server if anything happened.

Here is an example of a chat program that uses AJAX: http://www.dynamicajax.com/fr/JSON_AJAX_Web_Chat-.html

It isn't exactly what you are doing, but it demonstrates the concept of trying to check something after the page has been loaded and making the user's browser respond.

不能使用.NET版本的quartz-scheduler库(http://quartz-scheduler.org/)来基于配置定义和触发作业(cron表达式)。

当网站中没有打开任何会话时,iis会自动关闭网站应用程序以禁用此功能,您可以在iis中更改空闲时间或读取global.asax(application_end)函数中的网站链接以开始新的会话

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM