I don't know if you're using WPF or Windows forms.. Here's a WPF Example.
WebRequest w = HttpWebRequest.Create("http://www.google.com");
Dispatcher dispatcher = Dispatcher.CurrentDispatcher;
Thread thread = new Thread(new ThreadStart(() =>
{
WebResponse response = w.GetResponse();
dispatcher.BeginInvoke(new Action(() =>
{
// Handle response on the dispatcher thread.
}), null);
}));
thread.IsBackground = true;
thread.Start();
Notice the IsBackground = true. So your application will terminate it on exit. It's also possible to put HttpWebRequest.Create inside the thread method.
Windows.Form equivalent
WebRequest w = HttpWebRequest.Create("http://www.google.com");
Thread thread = new Thread(new ThreadStart(() =>
{
WebResponse response = w.GetResponse();
this.BeginInvoke(new Action(() =>
{
// Handle response on the dispatcher thread.
}), null);
}));
thread.IsBackground = true;
thread.Start();
Where this is a Form/Control