views:

37

answers:

1

Hey,
I'm using web refernce call in new working thread in my application as follow:

Thread callRunner = new Thread(delegate() 
    { _mediator.IncomingCallDetails(phoneNumber); }); 
callRunner.Start() ;   

the _mediator calls the web refernce and replay to the caller in event as follow:

void IncomingCallComplited(IncomingCallEventArg args)  
{  
    Caller = args.Caller;  
    Lodgers = args.Lodgers;  
    PreviousMissions = args.PreviousMissions;  
}  

Caller ,Lodgers and PreviousMissions are properties of an object that bind to GUI element,as for now the binding works fine and I can see the values from the web reference in screen my question is should I use Dispatcher in the event or in any other phase ? and if I do can someone please explain why? Thanks
Eran

A: 

Actually, the binding system takes care of that for you, so you don't need to explicitly marshal the call to the UI thread. However, this behavior is not documented (unless I missed it), so I'm not sure you should rely on it...

Also, note that although the PropertyChanged event is correctly marshalled across threads by the binding system, the CollectionChanged event is not. So if you're adding data from another thread to an ObservableCollection that is bound to the UI, you need to call Dispatcher.Invoke. Or you can use this custom ObservableCollection class, which raises the CollectionChanged event on the UI thread

Thomas Levesque
Thanks Thomas,it was just what i needed to know
Eran