저는 현재 두 창을 모두 찾고 있습니다. & wp8 apps (모두 sl 및 C# 프로젝트 임).windows dispatchcher, async를 얻는 올바른 방법을 저장합니다.
dispatcher를 가져 오는 것이 wpf와 다르며 Window.Current에서 비동기 메서드 중 일부에서 사라지는 것처럼 보입니다.
내가 할 수있는 것은 기본적으로 App 클래스에 propery를 넣는 것이었지만 안전하지 않은 것처럼 보였습니다. 여기서는 논리를 따르지 않습니다.
것으로 someMethod()가 호출internal class MainviewModel : ViewModelBase
{
..............
private async void GetLastDocumetAsync()
{
// Window.Current is null here, but not outside async!
await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,() =>
{
ObservableCollection<ScannedDocument> docs = await ServiceLocator.DocumentClient.GetLastScannedDocumentsAsync();
ScannedDocuments.AddRange(docs);
SelectedDocument = ScannedDocuments.LastOrDefault();
}
}
...
public void SomeMethod(){
// Window.Current is not null
Task.Factory.StartNew(() => GetLastDocumetAsync());
}
}
, Window.Current가 null가 아닌 :
나는 예를 게시합니다. 우리가 비동기 메서드에있을 때 디스패처가 필요하면 null입니다.
모든 포인터? 명시 적으로 캡처하고 컨텍스트의 복원이 필요하지 않도록
Brgds,
polkaextremist
Windows 운영 체제의 Silverlight? – jv42