OStateUserId 개체에 결과를 가져온 후이 문을 실행하고 싶습니다.
details.Text = OStateUserID.name + "\n" + OStateUserID.population);
bStateuserID.Click += async delegate
{
details.Text=" ";
Guid x = new Guid("33F8A8D5-0DF2-47A0-9C79-002351A95F88");
state OStateUserID =(state) await obj.GetStateByUserId(x.ToString());
details.Text = OStateUserID.name + "\n" + OStateUserID.population);
};
GetStateByUserId()
메서드는의 개체를 반환합니다 class State
.
비동기 적으로 실행됩니다. 작업 완료 후 TextView 세부 정보에 이름 과 인구 를 할당하고 싶습니다 .
RunOnUIThread()
이 경우 어떻게 사용할 수 있습니까?
그럴 필요가 없습니다.
이 코드에서 다음을 게시했습니다.
bStateuserID.Click += async delegate
{
details.Text=" ";
Guid x = new Guid("33F8A8D5-0DF2-47A0-9C79-002351A95F88");
state OStateUserID =(state) await obj.GetStateByUserId(x.ToString());
details.Text = OStateUserID.name + "\n" + OStateUserID.population);
};
라인
details.Text = OStateUserID.name + "\n" + OStateUserID.population);
이미 UI 스레드에서 실행 중입니다.
이 동작을 설명 하는 async
소개 가 블로그에 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다