Created
May 1, 2020 06:44
-
-
Save Clancey/824d3bcf85de10143de6195a3b878aff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Testclass { | |
Action<bool> MyAction { get; set; } | |
Func<Task<bool>> MyAwaitedAction { get; set; } | |
public async Task AsyncTestMethod() | |
{ | |
MyAction += (result) => { | |
Console.WriteLine(result); | |
}; | |
MyAwaitedAction += () => { | |
return Task.FromResult(true); | |
}; | |
MyAwaitedAction += () => { | |
return Task.FromResult(false); | |
}; | |
//Wait until the action completes. | |
//Only the last subscribed function will return; | |
var result = await MyAwaitedAction(); | |
MyAction.Invoke(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment