Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android异步任务奇怪的行为_Java_Android_Android Asynctask - Fatal编程技术网

Java Android异步任务奇怪的行为

Java Android异步任务奇怪的行为,java,android,android-asynctask,Java,Android,Android Asynctask,我必须完成我的任务来完成一些工作。 这是我的代码: class LoaderInfo : AsyncTask<Java.Lang.Void, Java.Lang.Void, Dictionary<String, String>> protected override void OnPreExecute() { base.OnPreExecute(); //Set the dialog for the user.

我必须完成我的任务来完成一些工作。 这是我的代码:

class LoaderInfo : AsyncTask<Java.Lang.Void, Java.Lang.Void, Dictionary<String, String>>
    protected override void OnPreExecute()
    {
        base.OnPreExecute();
        //Set the dialog for the user.
        pDialog = new ProgressDialog(this.context);
        pDialog.SetMessage(message);
        //It means the "loading amount" is not measured.
        pDialog.Indeterminate = true;
        //Sets whether this dialog is cancelable with the BACK key.
        pDialog.SetCancelable(false);
        pDialog.Show();
    }
protected override Dictionary<String, String> RunInBackground(paramsJava.Lang.Void[] @params)
{
    Dictionary<String, String> d = new Dictionary<String, String>();
    return d;
}
protected override void OnPostExecute(Dictionary<String, String> result)
{
    base.OnPostExecute(result);
    this.pDialog.Dismiss();
}
class LoaderInfo:AsyncTask
受保护的覆盖无效OnPreExecute()
{
base.OnPreExecute();
//为用户设置对话框。
pDialog=newprogressdialog(this.context);
pDialog.SetMessage(消息);
//这意味着“装载量”未测量。
pDialog.Undeterminate=真;
//设置此对话框是否可使用后退键取消。
pDialog.SetCancelable(假);
pDialog.Show();
}
受保护的覆盖字典运行背景(paramsJava.Lang.Void[]@params)
{
字典d=新字典();
返回d;
}
受保护的重写void OnPostExecute(字典结果)
{
base.OnPostExecute(结果);
this.pDialog.discouse();
}
问题是永远不会调用OnPostExecute! 我已经尝试过调试,但是“RunInBackground”(在官方文档中我没有看到这个方法,但是VisualStudio告诉我必须实现这个覆盖方法,而不是DoInBackground,为什么?)似乎没有返回任何结果

我已尝试使用此代码,一切正常:

class LoaderInfo : AsyncTask<Java.Lang.Void, Java.Lang.Void, Java.Lang.Void>
{

ProgressDialog pDialog;
Context context;

public LoaderInfo(Context context)
{
    this.context = context;
}
protected override void OnPreExecute()
{
    base.OnPreExecute();
    //Set the dialog for the user.
    pDialog = new ProgressDialog(this.context);
    String message = this.context.GetString(Resource.String.load);
    pDialog.SetMessage(message);
    //It means the "loading amount" is not measured.
    pDialog.Indeterminate = true;
    //Sets whether this dialog is cancelable with the BACK key.
    pDialog.SetCancelable(false);
    pDialog.Show();
}
protected override void OnPostExecute(Java.Lang.Void result)
{
    System.Console.WriteLine("OnPostExecute");
    base.OnPostExecute(result);
    this.pDialog.Dismiss();
}

protected override Java.Lang.Void RunInBackground(params Java.Lang.Void[] @params)
{
    return null; 
}
class LoaderInfo:AsyncTask
{
ProgressDialog;
语境;
公共加载程序信息(上下文)
{
this.context=上下文;
}
受保护的覆盖无效OnPreExecute()
{
base.OnPreExecute();
//为用户设置对话框。
pDialog=newprogressdialog(this.context);
String message=this.context.GetString(Resource.String.load);
pDialog.SetMessage(消息);
//这意味着“装载量”未测量。
pDialog.Undeterminate=真;
//设置此对话框是否可使用后退键取消。
pDialog.SetCancelable(假);
pDialog.Show();
}
受保护的重写void OnPostExecute(Java.Lang.void结果)
{
System.Console.WriteLine(“OnPostExecute”);
base.OnPostExecute(结果);
this.pDialog.discouse();
}
受保护的重写Java.Lang.Void RunInBackground(params Java.Lang.Void[]@params)
{
返回null;
}
} }

为什么我会有这个问题?我是我做错了什么


提前感谢您的帮助。

这是我的帮助,我已经阅读了这篇文章,但我找不到解决方案。
 protected override Void RunInBackground(params Void[] @params)
        {
            Java.Lang.Void jInt = null;
            return jInt;


        }