J
John
I've got some reasonably complex business logic in my C# code, in a class
called by a ASP.NET page. This takes around 3-4 seconds to execute. It's not
dependent on SQL calls or anything like that.
I know of the problems with the worker process doing two things at once from
the main thread pool (The old "Sit in a tight loop for 20 seconds and watch
all your webapps die!" issue). So I've worked around the issue by spawning
the business logic into a new thread. The main thread Sleep()'s until it's
finished, and then continues. eg:
Button_Click:
1) start new thread
2) Sleep until it's done
3) destroy it
New thread:
1) Do something heavy for a few seconds
2) terminate
I figured that, since the main thread is sleeping waiting for my new thread,
I don't need to lock() any objects, I can just access then directly.
It all seems to work fine, and has solved the strange delays my other
webapp-users were experiencing.
Does this sound like good practice?
Thanks,
John
called by a ASP.NET page. This takes around 3-4 seconds to execute. It's not
dependent on SQL calls or anything like that.
I know of the problems with the worker process doing two things at once from
the main thread pool (The old "Sit in a tight loop for 20 seconds and watch
all your webapps die!" issue). So I've worked around the issue by spawning
the business logic into a new thread. The main thread Sleep()'s until it's
finished, and then continues. eg:
Button_Click:
1) start new thread
2) Sleep until it's done
3) destroy it
New thread:
1) Do something heavy for a few seconds
2) terminate
I figured that, since the main thread is sleeping waiting for my new thread,
I don't need to lock() any objects, I can just access then directly.
It all seems to work fine, and has solved the strange delays my other
webapp-users were experiencing.
Does this sound like good practice?
Thanks,
John