views:

31

answers:

4

Hi everyone,

We'd like to track who's on our website and what pages they're looking at. The plan is to create a delegate (which will log visits to a database table) and call it asynchronously.

We're using .Net 3.5 and I don't know if the delegate idea, along with BeginInvoke and EndInvoke, is the way to go these days or if there are newer, improved methods-- a BackgroundWorker possibly, or something else. Not sure.

The idea is to keep as light an overhead as possible, since this processing will take place each time one of our pages is called. If we use a delegate it won't return a value, that's for sure. If you have any suggestions I'm glad to hear them. Thanks!

+1  A: 

ThreadPool.QueueWorkerItem is one simple way to do it. Just you logging request to the threadpool and it will do the action in a background thread, and you don't need to worry about it.

btlog
+1  A: 

Well if you are looking to just run a process and not wait for it to finish another easy way to do it would be to just kick off a new thread and run your code on that. Then you don't have to wait for it to return. Similar to the thought about the backgroundworker.

spinon
+1  A: 

You could use Javascript with XMLHttpRequest to load your other page if that's the way you want to go.

Instead of creating a single page, I'd put it in a base page from which your pages inherit. Then, use any async method that you prefer.

MCain
+1  A: 

Use the backgroundworker, won't use the ui thread, so won't slow your system down.

David