2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
13 #include <sdkddkver.h>
15 #ifndef TARGET_WINDOWS_STORE
16 #include <winrt/windows.foundation.h>
21 using namespace Windows::Foundation
;
26 #ifdef NTDDI_WIN10_CO // Windows SDK 10.0.22000.0 or newer
27 return winrt::impl::is_sta_thread();
29 return winrt::impl::is_sta();
33 inline void Wait(const winrt::IAsyncAction
& asyncOp
)
35 if (asyncOp
.Status() == winrt::AsyncStatus::Completed
)
41 auto __sync
= std::make_shared
<Concurrency::event
>();
42 asyncOp
.Completed([&](auto&&, auto&&) {
48 template <typename TResult
, typename TProgress
> inline
49 TResult
Wait(const winrt::IAsyncOperationWithProgress
<TResult
, TProgress
>& asyncOp
)
51 if (asyncOp
.Status() == winrt::AsyncStatus::Completed
)
52 return asyncOp
.GetResults();
57 auto __sync
= std::make_shared
<Concurrency::event
>();
58 asyncOp
.Completed([&](auto&&, auto&&) {
63 return asyncOp
.GetResults();
66 template <typename TResult
> inline
67 TResult
Wait(const winrt::IAsyncOperation
<TResult
>& asyncOp
)
69 if (asyncOp
.Status() == winrt::AsyncStatus::Completed
)
70 return asyncOp
.GetResults();
75 auto __sync
= std::make_shared
<Concurrency::event
>();
76 asyncOp
.Completed([&](auto&&, auto&&)
82 return asyncOp
.GetResults();
85 template <typename TResult
> inline
86 TResult
Wait(const Concurrency::task
<TResult
>& asyncOp
)
88 if (asyncOp
.is_done())
91 if (!is_sta()) // blocking suspend is allowed
94 auto _sync
= std::make_shared
<Concurrency::event
>();
95 asyncOp
.then([&](TResult result
)
101 return asyncOp
.get();