Subscribe to Fire and Forget async calls?
See original GitHub issueIs there a way to Subscribe
to a generic UniTask
? For example, I don’t want to await
a UniTask
but I want to do something with the result when it’s complete.
private async UniTask<string> GetPlayerName()
{
string playerName = await GetPlayerNameFromServer();
return playerName;
}
private void Awake()
{
GetPlayerName().Subscribe(name => PlayerPrefs.Set("playerName", name));
// other initialization
}
Issue Analytics
- State:
- Created a year ago
- Comments:7
Top Results From Across the Web
Proper way to start and fire-and-forget asynchronous calls?
First, you need to decide whether you really want fire-and-forget. ... is only calling a single method - eliding async and await is...
Read more >FIRE AND FORGET. — Asynchronous over Synchronous
This implies that you can make any number of calls, anytime without having to wait for a response. Simply “fire and forget”. Curious...
Read more >C# "fire and forget" method
Starting sync code inside "async void" method will be executed on the same thread of the main thread. That's "Thread.Sleep(3000)" means.
Read more >c# - Starting a fire and forget async method
Just fire the task without async/await. private void InitMethod(ServiceControl serviceControl) { if (serviceControl != null) { Task.Factory.
Read more >Can I fire-and-forget an async method? : r/csharp
Put simply, I want to call an async method and not await it. I'm coming from a background of managing my own threads....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ContinueWith<T>()
maybe help:I was just coming back here to callout
ContinueWith
, it has several useful overrides that make this work. Thanks all.