Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why enforce async/await method? #46

Closed
neonleo opened this issue Sep 2, 2022 · 2 comments
Closed

Why enforce async/await method? #46

neonleo opened this issue Sep 2, 2022 · 2 comments

Comments

@neonleo
Copy link

neonleo commented Sep 2, 2022

I would like use it in console and not async/await, how can I post/get in generic way?
Thanks

@iwate
Copy link
Owner

iwate commented Sep 6, 2022

@neonleo
You can use async main method after c# 7.1.
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.1/async-main

If you use c# ~v7.0, you can wrap mainasync method.

public static void Main()
{
    MainAsync().GetAwaiter().GetResult();
}

private static async Task MainAsync()
{
    ...
    var response = await odata.SendAsync(...);
}

And you can also use Task.Result.

public static void Main()
{
    ...
    var response = await odata.SendAsync(...).Result;
}

@neonleo
Copy link
Author

neonleo commented Sep 9, 2022

Thank you‼

@neonleo neonleo closed this as completed Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants