Unity3d로 Windows Phone 게임을 만들고 UI 스레드에서 Unity 스레드의 메서드를 비동기 적으로 호출해야합니다.Dispatcher.BeginInvoke 메서드 두 번째 실행 후 '고정'
이 모든 것이 작동하지만 한 가지 특별한 방법으로 첫 번째 실행이 예상대로 실행되지만 두 번째 이후에는 게임을 잠그는 것처럼 보입니다.
private async static Task<String> ShowDescriptionProductListing()
{
var x = await CurrentApp.LoadListingInformationAsync();
StringBuilder builder = new StringBuilder();
builder.AppendFormat("{0}\n{1}", x.Description,
x.ProductListings.FirstOrDefault().Value);
return builder.ToString();
}
public static void ShowDescrProduct()
{
string x = ShowDescriptionProductListing().Result;
MessageBox.Show(x);
}
나는 선을 생각 :
var x = await CurrentApp.LoadListingInformationAsync();
가장 가능성이 범인이다, 그러나 나는 힘든 시간을 디버깅하는 데 문제가 있습니다.
'보유'클래스는 단결에 그 방법과 같이이다 :
public static class HelperClass
{
public static void ShowDescrProduct()
{
Dispatcherr.InvokeOnUIThread(Tests.ShowDescrProduct); //The method above
}
}
Dispatcherr (그래 내가 하하 네임 스페이스를 사용해야합니다) 그냥 UI 스레드 내 설정이 개 동작 특성을 보유하고 있습니다. 항상 성공 -
public void EnterUIThread(Action action)
{
Dispatcher.BeginInvoke(() =>
{
action();
});
}
private void Unity_Loaded()
{
Dispatcherr.InvokeUIThread = EnterUIThread; //One of the actions I just
//mentioned being assigned the above
//method
}
는 그리고 첫 번째 호출 후, 갇혀 얻을 것 같다 Dispatcher.BeginInvoke하기 위해 EnterUIThread 호출에 있습니다.
다소 혼란 스러울 정도입니다.
누구나 통찰력을 줄 수 있습니까? 사전
감사합니다. Servy! :) –