Click here to Skip to main content
15,887,417 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can I assume that "GetDataComplete"'s async web service completed event is always invoked in the U/I thread? In which case the code below is redundant. Or is that good defense for scenarious where it may call from another thread.

C#
var svc = new ServiceTest.Service1Client();
svc.GetDataCompleted += (o, evt) =>
{
    if (null == evt.Error)
    {
        Dispatcher.BeginInvoke(() =>
                                   {
                                       label1.Content
                                           = evt.Result;
                                   }
            );
    }
};


Thanks!
Posted
Updated 21-Apr-11 4:47am
v2

It's handled wherever you add a handler. The way you've done it is prefectly fine, if not a little obfuscatory (I prefer defined methods instead of that lambda stuff).
 
Share this answer
 
I would say yes, it should be called on the same thread that GetDataAsync was called on.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900