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.
16 using namespace Windows::Foundation
;
19 inline void Wait(const winrt::IAsyncAction
& asyncOp
)
21 if (asyncOp
.Status() == winrt::AsyncStatus::Completed
)
24 if (!winrt::impl::is_sta())
27 auto __sync
= std::make_shared
<Concurrency::event
>();
28 asyncOp
.Completed([&](auto&&, auto&&) {
34 template <typename TResult
, typename TProgress
> inline
35 TResult
Wait(const winrt::IAsyncOperationWithProgress
<TResult
, TProgress
>& asyncOp
)
37 if (asyncOp
.Status() == winrt::AsyncStatus::Completed
)
38 return asyncOp
.GetResults();
40 if (!winrt::impl::is_sta())
43 auto __sync
= std::make_shared
<Concurrency::event
>();
44 asyncOp
.Completed([&](auto&&, auto&&) {
49 return asyncOp
.GetResults();
52 template <typename TResult
> inline
53 TResult
Wait(const winrt::IAsyncOperation
<TResult
>& asyncOp
)
55 if (asyncOp
.Status() == winrt::AsyncStatus::Completed
)
56 return asyncOp
.GetResults();
58 if (!winrt::impl::is_sta())
61 auto __sync
= std::make_shared
<Concurrency::event
>();
62 asyncOp
.Completed([&](auto&&, auto&&)
68 return asyncOp
.GetResults();
71 template <typename TResult
> inline
72 TResult
Wait(const Concurrency::task
<TResult
>& asyncOp
)
74 if (asyncOp
.is_done())
77 if (!winrt::impl::is_sta()) // blocking suspend is allowed
80 auto _sync
= std::make_shared
<Concurrency::event
>();
81 asyncOp
.then([&](TResult result
)