codingdir logo sitemap sitemap |
Home
PHP
C#
C++
ANDROID
JAVA
JAVASCRIPT
PYTHON

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


By : , Category : c#

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.

ReLated :

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.

Comments


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © codingdir.com All Rights Reserved .