You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: windows.foundation.collections/ikeyvaluepair_2.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,14 +13,14 @@ public interface IKeyValuePair<K, V> :
13
13
14
14
Represents a key-value pair. This is typically used as a constraint type when you need to encapsulate two type parameters into one to satisfy the constraints of another generic interface.
15
15
16
-
> **.NET**
17
-
> This interface appears as [System.Collections.Generic.KeyValuePair<TKey,TValue>](/dotnet/api/system.collections.generic.keyvaluepair-2?view=dotnet-uwp-10.0&preserve-view=true) (a structure, not an interface). In any case where a Windows Runtime type has implemented IKeyValuePair<K,V>, .NET code can use the APIs of [KeyValuePair](/dotnet/api/system.collections.generic.keyvaluepair-2?view=dotnet-uwp-10.0&preserve-view=true) instead.
16
+
> [!NOTE]
17
+
> In .NET, this interface appears as [System.Collections.Generic.KeyValuePair<TKey,TValue>](/dotnet/api/system.collections.generic.keyvaluepair-2?view=dotnet-uwp-10.0&preserve-view=true) (a structure, not an interface). In any case where a Windows Runtime type has implemented IKeyValuePair<K,V>, .NET code can use the APIs of [KeyValuePair](/dotnet/api/system.collections.generic.keyvaluepair-2?view=dotnet-uwp-10.0&preserve-view=true) instead.
18
18
19
19
## -remarks
20
20
21
21
When programming with .NET, this interface is hidden and developers should use the [System.Collections.Generic.KeyValuePair<TKey,TValue>](/dotnet/api/system.collections.generic.keyvaluepair-2?view=dotnet-uwp-10.0&preserve-view=true) structure. In any case where a Windows Runtime type has implemented IKeyValuePair<K,V>, including when interfaces have inherited IKeyValuePair<K,V> or used it as an inner constraint, .NET code can treat it as a .NET [KeyValuePair](/dotnet/api/system.collections.generic.keyvaluepair-2?view=dotnet-uwp-10.0&preserve-view=true).
22
22
23
-
Key-value pairs are used in the [IMap<K,V>](imap_2.md) interface, when it inherits [IIterable<T>](iiterable_1.md). Practical implementations of [IMap<K,V>](imap_2.md) are iterable, and iterating or calling [First](iiterable_1_first_1920739956.md)/[Current](iiterator_1_current.md) explicitly will return instances of IKeyValuePair<K,V> using the same constraints as does the [IMap<K,V>](imap_2.md) implementation.
23
+
Key-value pairs are used in the [IMap<K,V>](imap_2.md) interface, when it inherits [IIterable<T>](iiterable_1.md). Practical implementations of [IMap<K,V>](imap_2.md) are iterable, and iterating or calling [First](iiterable_1_first_1920739956.md)/[Current](iiterator_1_current.md) explicitly will return instances of IKeyValuePair<K,V> using the same constraints as does the [IMap<K,V>](imap_2.md) implementation.
24
24
25
25
### C++/WinRT extension functions
26
26
@@ -47,10 +47,10 @@ is equivalent to,
47
47
auto key = kvp.Key();
48
48
auto value = kvp.Value();
49
49
```
50
-
50
+
51
51
Structured binding is particularly convenient in range-based `for` loops, letting you iterate through the key/value pairs of a map.
Copy file name to clipboardExpand all lines: windows.foundation/iasyncaction.md
+17-11Lines changed: 17 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,39 +10,44 @@ public interface IAsyncAction : Windows.Foundation.IAsyncInfo
10
10
# Windows.Foundation.IAsyncAction
11
11
12
12
## -description
13
-
Represents an asynchronous action. This is the return type for many Windows Runtime asynchronous methods that don't have a result object, and don't report ongoing progress.
13
+
14
+
Represents an asynchronous action. This is the return type for many Windows Runtime (WinRT) asynchronous methods that don't have a result object, and don't report ongoing progress.
14
15
15
16
## -remarks
16
-
IAsyncAction is the return type for all Windows Runtime asynchronous methods that don't communicate a result object, or ongoing progress. This constitutes over 300 different Windows Runtime APIs. APIs that do report progress (but don't have a result) use another interface, [IAsyncActionWithProgress<TProgress>](iasyncactionwithprogress_1.md).
17
17
18
-
When you use methods that return IAsyncAction in your app code, you usually don't access the IAsyncAction return value directly. That's because you almost always use the language-specific awaitable syntax. In this case, the apparent return value of the method is **void**. For more info, see [Asynchronous programming](/windows/uwp/threading-async/asynchronous-programming-universal-windows-platform-apps), or one of the language-specific guides to Windows Runtime asynchronous programming ([Call asynchronous APIs in C# or Visual Basic](/windows/uwp/threading-async/call-asynchronous-apis-in-csharp-or-visual-basic), [C++](/windows/uwp/threading-async/asynchronous-programming-in-cpp-universal-windows-platform-apps), [JavaScript](/previous-versions/windows/apps/hh700330(v=win.10))).
18
+
`IAsyncAction` is the return type for all WinRT asynchronous methods that don't communicate a result object, or ongoing progress. This constitutes over 300 different WinRT APIs. APIs that report progress but don't have a result use another interface, [IAsyncActionWithProgress<TProgress>](iasyncactionwithprogress_1.md).
19
+
20
+
When you use methods that return `IAsyncAction` in your app code, you usually don't access the `IAsyncAction` return value directly. That's because you almost always use the language-specific awaitable syntax. In this case, the apparent return value of the method is **void**. For more info, see [Asynchronous programming](/windows/uwp/threading-async/asynchronous-programming-universal-windows-platform-apps), or one of the language-specific guides to WinRT asynchronous programming ([Call asynchronous APIs in C# or Visual Basic](/windows/uwp/threading-async/call-asynchronous-apis-in-csharp-or-visual-basic), [C++](/windows/uwp/threading-async/asynchronous-programming-in-cpp-universal-windows-platform-apps), [JavaScript](/previous-versions/windows/apps/hh700330(v=win.10))).
21
+
22
+
`IAsyncAction` is also an input type for some advanced-scenario utility APIs such as [CoreDispatcher.RunAsync](../windows.ui.core/coredispatcher_runasync_447339746.md) and [ThreadPool.RunAsync](../windows.system.threading/threadpool_runasync_514988780.md).
19
23
20
-
IAsyncAction is also an input type for some advanced-scenario utility APIs such as [CoreDispatcher.RunAsync](../windows.ui.core/coredispatcher_runasync_447339746.md) and [ThreadPool.RunAsync](../windows.system.threading/threadpool_runasync_514988780.md).
24
+
It's not common to use `IAsyncAction` directly even if you don't use a language-specific awaitable syntax. Each of the languages has extension points that are generally easier to use than the WinRT interface. JavaScript has [WinJS.Promise](/previous-versions/windows/apps/br211867(v=win.10)), and the `then`/`done` syntax. .NET has the [AsTask](/dotnet/api/system.windowsruntimesystemextensions.astask?view=dotnet-uwp-10.0&preserve-view=true) extension method, and once the `IAsyncAction` is converted to a [Task](/dotnet/api/system.threading.tasks.task?view=dotnet-uwp-10.0&preserve-view=true), it's easier to cancel, get notification on completion, and so on. For C++/CX, you can wrap the calls using the [Concurrency runtime](/cpp/parallel/concrt/reference/concurrency-namespace) (and use [create_task](/cpp/parallel/concrt/reference/concurrency-namespace-functions?view=vs-2017)). In other words, `IAsyncAction` can be considered runtime-level infrastructure, which each of the languages use as a framework to support awaitable syntax or asynchronous programming models in their own way.
21
25
22
-
It's not common to use IAsyncAction directly even if you don't use a language-specific awaitable syntax. Each of the languages has extension points that are generally easier to use than the Windows Runtime interface. JavaScript has [WinJS.Promise](/previous-versions/windows/apps/br211867(v=win.10)), and the **then/done** syntax. .NET has the [AsTask](/dotnet/api/system.windowsruntimesystemextensions.astask?view=dotnet-uwp-10.0&preserve-view=true) extension method, and once the IAsyncAction is converted to a [Task](/dotnet/api/system.threading.tasks.task?view=dotnet-uwp-10.0&preserve-view=true), it's easier to cancel, get notification on completion, and so on. For C++/CX, you can wrap the calls using the [Concurrency runtime](/cpp/parallel/concrt/reference/concurrency-namespace) (and use [create_task](/cpp/parallel/concrt/reference/concurrency-namespace-functions?view=vs-2017)). In other words, IAsyncAction can be considered runtime-level infrastructure, which each of the languages use as a framework to support awaitable syntax or asynchronous programming models in their own way.
26
+
Instead of using `IAsyncAction`, some WinRT asynchronous methods use custom action types (which might have "Operation" rather than "Action" in their name). For example, [SignOutUserOperation](../windows.security.authentication.onlineid/signoutuseroperation.md) is a WinRT type that implements `IAsyncAction`. The [SignOutUserOperation](../windows.security.authentication.onlineid/signoutuseroperation.md) type is then used as the custom action return type for the [SignOutUserAsync](../windows.security.authentication.onlineid/onlineidauthenticator_signoutuserasync_658229157.md) method.
23
27
24
-
Instead of using IAsyncAction, some Windows Runtime asynchronous methods use custom action types (which might have "Operation" rather than "Action" in their name). For example, [SignOutUserOperation](../windows.security.authentication.onlineid/signoutuseroperation.md) is a Windows Runtime type that implements IAsyncAction. The [SignOutUserOperation](../windows.security.authentication.onlineid/signoutuseroperation.md) type is then used as the custom action return type for the [SignOutUserAsync](../windows.security.authentication.onlineid/onlineidauthenticator_signoutuserasync_658229157.md) method.
28
+
If you have a method that returns a .NET `Task` and need an `IAsyncAction` to pass to a WinRT API, you can use the [AsAsyncAction](/dotnet/api/system.windowsruntimesystemextensions.asasyncaction?view=dotnet-uwp-10.0&preserve-view=true) extension method.
25
29
26
30
### C++/WinRT extension functions
27
31
28
32
> [!NOTE]
29
-
> Extension functions exist on the C++/WinRT projection types for certain Windows Runtime APIs. For example, **winrt::Windows::Foundation::IAsyncAction** is the C++/WinRT projection type for **IAsyncAction**. The extension functions aren't part of the application binary interface (ABI) surface of the actual Windows Runtime types, so they're not listed as members of the Windows Runtime APIs. But you can call them from within any C++/WinRT project. See [C++/WinRT functions that extend Windows Runtime APIs](/uwp/cpp-ref-for-winrt/winrt#cwinrt-functions-that-extend-windows-runtime-apis).
33
+
> Extension functions exist on the C++/WinRT projection types for certain WinRT APIs. For example, `winrt::Windows::Foundation::IAsyncAction` is the C++/WinRT projection type for `IAsyncAction`. The extension functions aren't part of the application binary interface (ABI) surface of the actual WinRT types, so they're not listed as members of the WinRT APIs. But you can call them from within any C++/WinRT project. See [C++/WinRT functions that extend Windows Runtime APIs](/uwp/cpp-ref-for-winrt/winrt#cwinrt-functions-that-extend-windows-runtime-apis).
30
34
31
35
```cppwinrt
32
36
void get() const;
33
37
```
34
38
35
-
Waits synchronously for the action to complete. Throws a corresponding exception if the action is canceled, or enters an error state. You mustn't call it from a single-threaded apartment. For more info, and code examples showing how to call **get**, see [Write a coroutine](/windows/uwp/cpp-and-winrt-apis/concurrency#write-a-coroutine).
39
+
Waits synchronously for the action to complete. Throws a corresponding exception if the action is canceled, or enters an error state. You mustn't call it from a single-threaded apartment. For more info, and code examples showing how to call `get`, see [Write a coroutine](/windows/uwp/cpp-and-winrt-apis/concurrency#write-a-coroutine).
Waits synchronously for the action to complete, or for the specified timeout. Returns the state of the **IAsyncAction**, or [AsyncStatus::Started](/uwp/api/windows.foundation.asyncstatus) if the timeout elapsed. If the action didn't time out, then call [GetResults](/uwp/api/windows.foundation.iasyncaction.getresults) to obtain the results of the action. For more info, and code examples showing how to call **wait_for**, see [Asynchronous timeouts made easy](/windows/uwp/cpp-and-winrt-apis/concurrency-2#asynchronous-timeouts-made-easy).
45
+
Waits synchronously for the action to complete, or for the specified timeout. Returns the state of the `IAsyncAction`, or [AsyncStatus::Started](/uwp/api/windows.foundation.asyncstatus) if the timeout elapsed. If the action didn't time out, then call [GetResults](/uwp/api/windows.foundation.iasyncaction.getresults) to obtain the results of the action. For more info, and code examples showing how to call `wait_for`, see [Asynchronous timeouts made easy](/windows/uwp/cpp-and-winrt-apis/concurrency-2#asynchronous-timeouts-made-easy).
42
46
43
47
### Interface inheritance
44
48
45
-
IAsyncAction inherits [IAsyncInfo](iasyncinfo.md). Types that implement IAsyncAction also implement the interface members of [IAsyncInfo](iasyncinfo.md):
49
+
`IAsyncAction` inherits [IAsyncInfo](iasyncinfo.md). Types that implement `IAsyncAction` also implement the interface members of [IAsyncInfo](iasyncinfo.md):
As with calling the existing methods, there are language-specific ways to define asynchronous methods that don't use [IAsyncInfo](iasyncinfo.md) directly. If writing code using .NET, your method can return a [Task](/dotnet/api/system.threading.tasks.task?view=dotnet-uwp-10.0&preserve-view=true). For C++/CX, you can use the [Concurrency runtime](/cpp/parallel/concrt/reference/concurrency-namespace). However, if you're defining a [component](/previous-versions/windows/apps/hh441572(v=vs.140)), you can use **Task**/**task** internally but you must return one of the Windows Runtime interfaces for your public methods. The language-specific asynchronous support types (and many other language-specific types you might conventionally use in code) can't be used for the public surface area of a Windows Runtime component.
59
+
As with calling the existing methods, there are language-specific ways to define asynchronous methods that don't use [IAsyncInfo](iasyncinfo.md) directly. If writing code using .NET, your method can return a [Task](/dotnet/api/system.threading.tasks.task?view=dotnet-uwp-10.0&preserve-view=true). For C++/CX, you can use the [Concurrency runtime](/cpp/parallel/concrt/reference/concurrency-namespace). However, if you're defining a [component](/previous-versions/windows/apps/hh441572(v=vs.140)), you can use `Task`/`task` internally but you must return one of the WinRT interfaces for your public methods. The language-specific asynchronous support types (and many other language-specific types you might conventionally use in code) can't be used for the public surface area of a WinRT component.
0 commit comments