Language: C#
Accessing the UI thread from asynchronous handlers
1: // handle the completed event 2: _Service.MyMethodCompleted += (s, e) => 3: { 4: // an Action is just a built-in delegate 5: Action _Action = () => 6: { 7: // access the UI here 8: this.MyLabel.Text = e.Result; 9: } 10: // change the thread context 11: this.Invoke(_Action); 12: } 13: // call the async method 14: _Service.MyMethodAsync();
Tags:
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

