Click here to Skip to main content
15,867,895 members
Home / Discussions / C#
   

C#

 
GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
Exoskeletor2-Oct-21 3:58
Exoskeletor2-Oct-21 3:58 
GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
Exoskeletor2-Oct-21 2:58
Exoskeletor2-Oct-21 2:58 
AnswerRe: Can't catch NullReferenceException while explicitly defined for that Pin
Pete O'Hanlon3-Oct-21 20:22
subeditorPete O'Hanlon3-Oct-21 20:22 
GeneralRe: Can't catch NullReferenceException while explicitly defined for that Pin
Exoskeletor4-Oct-21 0:21
Exoskeletor4-Oct-21 0:21 
Questionhow read file from Open with in C# Pin
Member 1522978130-Sep-21 6:24
Member 1522978130-Sep-21 6:24 
AnswerRe: how read file from Open with in C# Pin
Dave Kreskowiak30-Sep-21 8:08
mveDave Kreskowiak30-Sep-21 8:08 
AnswerRe: how read file from Open with in C# Pin
Luc Pattyn30-Sep-21 8:30
sitebuilderLuc Pattyn30-Sep-21 8:30 
QuestionQuestion About Async Pin
Kevin Marois29-Sep-21 10:21
professionalKevin Marois29-Sep-21 10:21 
I see a lot of tutorials and examples that define controller methods like this:
[HttpGet]
public async Task<IEnumerable<Book>> GetBooks()
{
    return await _bookRepository.Get();
}

[HttpGet("{id}")]
public async Task<ActionResult<Book>> GetBooks(int id)
{
    return await _bookRepository.Get(id);
}
In these examples, the method signature returns a Task so that the method is async.

But can I just do this in my front end?
private async void LoadBooks()
{
    List books = null;

    await Task.Run(() =>
    {
        books = _proxy.GetBooks()

    }).ContinueWith(x => 
    {
        Books = new List(books);
    });
}

Why make the controller methods return task and use await? Doesn't my front end code acheive that?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 29-Sep-21 17:47pm.

AnswerRe: Question About Async Pin
Pete O'Hanlon29-Sep-21 20:22
subeditorPete O'Hanlon29-Sep-21 20:22 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 4:24
professionalKevin Marois30-Sep-21 4:24 
GeneralRe: Question About Async Pin
Richard Deeming30-Sep-21 4:41
mveRichard Deeming30-Sep-21 4:41 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 4:48
professionalKevin Marois30-Sep-21 4:48 
GeneralRe: Question About Async Pin
Richard Deeming30-Sep-21 5:05
mveRichard Deeming30-Sep-21 5:05 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 5:20
professionalKevin Marois30-Sep-21 5:20 
AnswerRe: Question About Async Pin
Richard Deeming29-Sep-21 21:54
mveRichard Deeming29-Sep-21 21:54 
GeneralRe: Question About Async Pin
Kevin Marois30-Sep-21 4:23
professionalKevin Marois30-Sep-21 4:23 
QuestionMakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff28-Sep-21 5:45
professionalBillWoodruff28-Sep-21 5:45 
AnswerRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
Richard Deeming28-Sep-21 6:20
mveRichard Deeming28-Sep-21 6:20 
GeneralRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff28-Sep-21 9:47
professionalBillWoodruff28-Sep-21 9:47 
AnswerRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
OriginalGriff28-Sep-21 6:30
mveOriginalGriff28-Sep-21 6:30 
GeneralRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff28-Sep-21 10:19
professionalBillWoodruff28-Sep-21 10:19 
GeneralRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
OriginalGriff28-Sep-21 10:40
mveOriginalGriff28-Sep-21 10:40 
GeneralRe: MakeGenericType/CreateInstance Object to underlying Type at run-time: why this works is driving me crazy Pin
BillWoodruff29-Sep-21 0:57
professionalBillWoodruff29-Sep-21 0:57 
Questionled matrix display Pin
Member 1537173026-Sep-21 7:49
Member 1537173026-Sep-21 7:49 
AnswerRe: led matrix display Pin
OriginalGriff26-Sep-21 8:33
mveOriginalGriff26-Sep-21 8:33 

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.