Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I count List in Task?

Tags:

c#

list

count

task

private async Task<List<T>> Ex_Event(string telNo)
{
    SearchConditionData scd = new SearchConditionData { tel=telNo };            
    List<T> list = await RequestAsync<SearchConditionData, List<T>>(scd, Service.GetIncident);

    historyList = ( ... ).Take(30).ToList();          

    return historyList;
}

I made a method that returns List<>.

But I modified it async, then I can't use List.Count.

Here are some part of my code.

public delegate Task<List<IncidentListData>> HistoryEvent(string telNo);
public event HistoryEvent myHistoryEvent;

Return Type is Task<>. And I want to check the count List in Task.

if (myHistoryEvent(Tel).Count > 0)

But it does not work. And I can't use async, because I called myHistoryEvent() in Interface that public string this[string name] (IDataErrorInfo)

How Can I check the count of List in Task??

like image 333
parfum Avatar asked Apr 06 '17 05:04

parfum


1 Answers

You can check with result of your task.

myHistoryEvent(Tel).Result.Count > 0

Inside result type List Task>.Result.

like image 116
orhun.begendi Avatar answered Oct 04 '22 12:10

orhun.begendi