
September 8, 2010 21:17 by
Brian Keating |
A sample of using SyncronizationContext to post a message back to the UX thread
private void Window_Loaded(object sender, RoutedEventArgs e)
{
SynchronizationContext ctx = SynchronizationContext.Current;
ThreadPool.QueueUserWorkItem(_ =>
{
WebClient client = new WebClient();
string html = client.DownloadString("http://www.briankeating.net");
ctx.Post(state =>
{
tbDetails.Text = (string)state;
}, html);
});
}
About Brian Keating
Professional Software Developer, .NET / C++ / Java View all posts by
Brian Keating →