how do I populate a List from multiple methods with Task>?

It sounds like you're just trying to convert a List<string>[] into an IEnumerable<string>, which isn't async-specific... plain LINQ will do it:

var errors = results.SelectMany(x => x);

That will flatten the array of lists to just a single sequence.

In this answer we use tpartition/4 in combination with if_/3 and (=)/3.

We define list_duplicateset/2 like this:

list_duplicateset([], []).
list_duplicateset([E|Xs0], Ys0) :-
   tpartition(=(E), Xs0, Es, Xs),
   if_(Es = [],
       Ys0 = Ys,
       Ys0 = [E|Ys]),
   list_duplicateset(Xs, Ys).

First, we run a sample query taken from this answer to a similar question:

?- list_duplicateset([1,2,2,3,4,5,7,6,7], Xs). 
Xs = [2,7].

Next, let's run the queries the OP gave:

?- list_duplicateset([a,b,c,a,a,b,e,f,g], Xs).
Xs = [a, b].

?- list_duplicateset([a,a,a,a,a], Xs).
Xs = [a].

?- list_duplicateset([a,b,c,d,e,f,g], Xs).
Xs = [].

Note that all queries presented above give the expected answers and succeed deterministically.

There are different ways to implement your requirements. The answer for example describes how one can fill userdata inside of beforeProcessing based on subData part of every item. I would recommend you additionally to read the answer which seems could makes visualization of your data more comfortable for the user.

If you're extending List you should just be able to call all the usual methods ie (add, addrange, remove etc..). Personally I would either extend IEnumerable or use Columns as a wrapper class with a member of type List but each to their own and it of course depends on what you're doing. Especially since you know the type of the list beforehand and you're handling the login in internal functions anyway, i would just have it as a member.

AsyncTasks are quite inefficient, so I would suggest using only one AsyncTask. That would solve all your current problems. You would show progress in onPreExecute, loop trough Relationships in doInBackground, update your adapter in onProgressUpdate and hide progress in onPostExecute.


Message :
Login to Add Your Comments .
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © All Rights Reserved .