views:

291

answers:

1

Hello, I have created an simple web server, leveraging .NET HttpListener class. I am using ThreadPool.QueueUserWorkItem() to spawn a thread to listen to incoming requests. Threaded method uses HttpListener.BeginGetContext(callback, listener), and in callback method I resume with HttpListener.EndGetContext() as well as raise an even to notify UI that listener received data. This is the question - how to raise that event?

Initially I used ThreadPool:

ThreadPool.QueueUserWorkItem(state => ReceivedRequest(httpListenerContext, receivedRequestArgs));

But then started to doubt, maybe it should be a dedicated thread (as appose to waiting for a thread from pool):

new Thread(() => ReceivedRequest(httpListenerContext, receivedRequestArgs)).Start();

Thoughts? 10X

A: 

I have figured this out.

Sean
If you wanted to explain what you did for posterity. Other's might gain something from it.
Master Morality
I ended up implementing async operation using ThreadPool.QueueUserWorkItem.
Sean