locked
I got the errors:system.threading.tasks can not be used with argument???

    Question

  • public async System.Threading.Task<List<Models.MainModels>> Loading(string id) { List<Models.MainModels> arrays = new List<Models.MainModels>(); ... return arrays; }

    show "can not be used with argument" up at

    System.Threading.Task<List<Models.MainModels>>
    Tuesday, March 31, 2015 9:34 AM

Answers

  • Hi Greg,

    The return value of a Task should not be an array, should be something like Task<array>.

    Besides I don't think System.Threading has Task class, but instead you should use

    System.Threading.Tasks.Task

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 1, 2015 7:07 AM
    Moderator
  • You should use the Task class in the System.Threading.Tasks namespace: https://msdn.microsoft.com/en-us/library/windows/apps/dd321424.aspx

    public async System.Threading.Tasks.Task<List<Models.MainModels>> Loading(string id)
    {
    List<Models.MainModels> arrays = new List<Models.MainModels>();
    ...
    return arrays;
    }

    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question.

    Wednesday, April 1, 2015 11:06 AM

All replies

  • Hi Greg,

    The return value of a Task should not be an array, should be something like Task<array>.

    Besides I don't think System.Threading has Task class, but instead you should use

    System.Threading.Tasks.Task

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 1, 2015 7:07 AM
    Moderator
  • You should use the Task class in the System.Threading.Tasks namespace: https://msdn.microsoft.com/en-us/library/windows/apps/dd321424.aspx

    public async System.Threading.Tasks.Task<List<Models.MainModels>> Loading(string id)
    {
    List<Models.MainModels> arrays = new List<Models.MainModels>();
    ...
    return arrays;
    }

    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question.

    Wednesday, April 1, 2015 11:06 AM