Click here to Skip to main content
15,891,431 members
Home / Discussions / C#
   

C#

 
GeneralRe: Incomplete data after trapping Date Pin
Robert Kamarowski8-Dec-15 10:25
Robert Kamarowski8-Dec-15 10:25 
GeneralRe: Incomplete data after trapping Date Pin
Richard Deeming9-Dec-15 2:56
mveRichard Deeming9-Dec-15 2:56 
GeneralRe: Incomplete data after trapping Date Pin
Robert Kamarowski9-Dec-15 5:07
Robert Kamarowski9-Dec-15 5:07 
QuestionTask.ContinueWith Return Value Pin
Kevin Marois8-Dec-15 5:19
professionalKevin Marois8-Dec-15 5:19 
AnswerRe: Task.ContinueWith Return Value Pin
Richard Deeming8-Dec-15 6:04
mveRichard Deeming8-Dec-15 6:04 
GeneralRe: Task.ContinueWith Return Value Pin
Dave Kreskowiak8-Dec-15 6:09
mveDave Kreskowiak8-Dec-15 6:09 
GeneralRe: Task.ContinueWith Return Value Pin
Kevin Marois8-Dec-15 6:22
professionalKevin Marois8-Dec-15 6:22 
AnswerRe: Task.ContinueWith Return Value Pin
Dave Kreskowiak8-Dec-15 6:08
mveDave Kreskowiak8-Dec-15 6:08 
Well, you're saying that GetAllNamesAsync() should be returning a Task, which returns a Dictionary<>. With the code, as written, there's nothing you can put in there to fix this. The whole method has to be rewritten a bit.

The second task you create, with ContinueWith doesn't specify a return type (void), but it looks like you're trying to return the Dictionary<> from that task, so it needs to be changed to specify that return type. I think you're looking for something more like this:
public Task<Dictionary<int, string>> GetAllNamesAsync()
{
    Task<IList<InternalProviderViewDto>> task = Client.GetAsync(new InternalProviderSearch());

    Task<Dictionary<int, string>> x = task.ContinueWith<IDictionary<int, string>>(t =>
    {
        IList<InternalProviderViewDto> results = t.Result;

        Dictionary<int, string> dict = new Dictionary<int, string>();

        foreach (var result in results)
        {
            dict.Add(result.Id, result.Name);
        }

        return dict;
    });

    return x;
}

A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

GeneralRe: Task.ContinueWith Return Value Pin
Kevin Marois8-Dec-15 6:23
professionalKevin Marois8-Dec-15 6:23 
GeneralRe: Task.ContinueWith Return Value Pin
Dave Kreskowiak8-Dec-15 7:20
mveDave Kreskowiak8-Dec-15 7:20 
QuestionMessage Removed Pin
7-Dec-15 15:59
Eilson Tang7-Dec-15 15:59 
AnswerMessage Removed Pin
7-Dec-15 16:38
professionalBillWoodruff7-Dec-15 16:38 
GeneralMessage Removed Pin
7-Dec-15 16:43
Eilson Tang7-Dec-15 16:43 
GeneralMessage Removed Pin
7-Dec-15 16:56
professionalBillWoodruff7-Dec-15 16:56 
QuestionThreads and Dispatcher Pin
Member 121764286-Dec-15 6:23
Member 121764286-Dec-15 6:23 
AnswerRe: Threads and Dispatcher Pin
Richard Deeming7-Dec-15 1:22
mveRichard Deeming7-Dec-15 1:22 
Questionhow Select a DataGridView row after TextBox value c# Pin
Carlos_paiva5-Dec-15 0:58
Carlos_paiva5-Dec-15 0:58 
AnswerRe: how Select a DataGridView row after TextBox value c# Pin
OriginalGriff5-Dec-15 1:23
mveOriginalGriff5-Dec-15 1:23 
QuestionMaking a program that converts speech to text Pin
Member 120871384-Dec-15 19:10
Member 120871384-Dec-15 19:10 
AnswerRe: Making a program that converts speech to text Pin
BillWoodruff4-Dec-15 22:55
professionalBillWoodruff4-Dec-15 22:55 
Questionhow to update the datagrid present on c# gui from c# dll. Pin
Member 93228874-Dec-15 7:49
Member 93228874-Dec-15 7:49 
AnswerRe: how to update the datagrid present on c# gui from c# dll. Pin
Eddy Vluggen4-Dec-15 7:58
professionalEddy Vluggen4-Dec-15 7:58 
AnswerRe: how to update the datagrid present on c# gui from c# dll. Pin
OriginalGriff4-Dec-15 8:02
mveOriginalGriff4-Dec-15 8:02 
AnswerRe: how to update the datagrid present on c# gui from c# dll. Pin
OriginalGriff4-Dec-15 8:24
mveOriginalGriff4-Dec-15 8:24 
QuestionSending emails Pin
Mohammad Imran Ahmed4-Dec-15 1:29
professionalMohammad Imran Ahmed4-Dec-15 1:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.