UIAlertViewは作業が完了した後にのみ表示されるため、Monotouchで非同期にWebサービス呼び出しを行う必要があります。
現在のコード(疑似)
Class LoginviewController
{
void Login(credentials)
{
showAlert("Logging in") ;
bool authenticated = service.Authenticate(Credentials);
}
}
class Service
{
Public bool Authenticate(object Credentials)
{
object[] results = this.Invoke("GetAuth", Credentials)
}
}
私はServiceメソッドを非同期モデルに移行する過程にあります。AuthenticateBeginAuthenticate(), EndAuthenticate(), AuthenticateAsync(), OnAuthenticateOperationCompleted()
はもちろん構成されていAuthenticate()
ます。
これらすべてが完了したら、LoginViewControllerでOnAuthenticateCompleted()を実行する必要があるため、次を使用します。BeginInvokeOnMainThread(delegate....
これは私が立ち往生しているところです。
OnAuthenticateCompleted()
LoginViewControllerクラスインスタンスのメソッドをservicesクラスから実行するにはどうすればよいですか?
編集:解決策:
Login()に接続され、Authenticate()の代わりにAuthenticateAsync()メソッドを呼び出すOnAuthenticateCompletedイベントハンドラーが追加されました。
Class LoginviewController
{
void Login(credentials)
{
showAlert("Logging in") ;
service.AuthenticateCompleted += new GetAuthenticationCompletedEventHandler(OnAuthenticateCompleted);
service.AuthenticateAsync(Credentials);
}
public void OnAuthenticateCompleted(obj sender, GetAuthenticationCompletedEventArgs args)
{
bool authenticated = (bool)args.Results;
//do stuff
hideAlert();
}
}