'cross-thread'에 해당되는 글 1건

  1. 2011.03.31 [wp7] MVVM에서의 Invalid cross-thread access.메세지
Windows Phone 72011. 3. 31. 17:54

이란 에러 메세지를 자주 본다.

 

만약 behind코드(xaml.cs)라면

 

Dispatcher.BeginInvoke(() =>
                                    {
                                        NavigationService.Navigate(new Uri("/Views/RecordView.xaml", UriKind.RelativeOrAbsolute));
                                    });

 

이렇게 쓰면 되겠지만

 

ViewModel 이나 Service에서는 어떻할까?

 

Deployment.Current.Dispatcher.BeginInvoke( ()=>
                       {
                           ServiceLocator.Current.LocationPermissionViewModel.NoButtonClick(null);
                       });

 

이렇게 쓰면 된다.

 

참조 : http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/43177228-1ab2-4489-afea-89b0bf61bdd7

Posted by 동동(이재동)