Background thread that loads data in asp.net
I want to load data to my application domain using a thread so it will be executed at all times. How can I achieve this? I want the thread will start when iis starts and terminate when iis exits.
Note: I want to do this so I开发者_开发技巧 can use disconnected architecture in my asp.net application.
Thanks in advance, Kfir
Kfir,
The simplest way to do this is to launch a blocking background-worker during the App_Start() method on Global.asax and then to kill it using App_Stop() in Global.asax.
Have the thread sit on a WaitHandle until it's ready for more data and then signal it to wait back up. Or if you really wanted to code something ghetto, you could just have it poll on a fixed interval using a timer.
精彩评论