Closed MrRickwi closed 3 years ago
Hello @MrRickwi could you point me to the right documentation where I can learn about this a little more?
If you look in Microsoft code reference, you will find the following comment:
/// <summary>Provides an awaitable object that allows for configured awaits on <see cref="System.Threading.Tasks.Task"/>.</summary> /// <remarks>This type is intended for compiler use only.</remarks> public struct ConfiguredTaskAwaitable {
This shows you that the struct should not be used.
Generally, use async Task<T>
as result instead of ConfiguredTaskAwaitable<T>
, and use ConfigureAwait(false)
instead of ConfigureAwait(true)
, see here.
Most of the methods in MediaElement
which return ConfiguredTaskAwaitable
due to the ConfigureAwait
should be rewritten like this:
public async Task<bool> ChangeMedia() { try { return await MediaCore.ChangeMedia().ConfigureAwait(false); } catch (Exception ex) { PostMediaFailedEvent(ex); } return false; }
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
ConfiguredTaskAwaitable shall not be used
ConfiguredTaskAwaitable is a struct that is only meant for use by the compiler. It should be replaced by clean async/await pattern using async Task instead.
Issue Categories