1
我想知道如何使用這個Android的AsyncTask .NET的異步庫來實現:轉換的AsyncTask到任務中MonoDroid的/ C#
public class LoadRecordTask : AsyncTask
{
private Activity1 _context;
private int _recordId;
public LoadRecordTask(Activity1 outerActivity, int recordId)
{
_context = outerActivity;
_recordId = recordId;
}
protected override void OnPreExecute()
{
base.OnPreExecute();
_progressDialog = Android.App.ProgressDialog.Show(_context , "", "Loading record {0}", _recordId);
}
protected override Java.Lang.Object DoInBackground(params Java.Lang.Object[] @params)
{
_bSuccess = LoadRecord(_recordId);
if(!_bSuccess)
{
return false;
}
return true;
}
protected override void OnPostExecute(Java.Lang.Object result)
{
base.OnPostExecute(result);
if(!_bSuccess)
{
_progressDialog.SetMessage("Error loading recording.");
}
_progressDialog.Dismiss();
}
}
我正在使用許多異步任務,這太棒了。值得一提的是,如果你有計劃讓一個應用程序的「純粹」android/java版本,這將減緩移植過程。從Xamarin最近的成功看起來並不令人擔憂。 – samosaris