5
5
using System ;
6
6
using System . Threading . Tasks ;
7
7
using Windows . ApplicationModel . AppService ;
8
+ using Windows . Foundation ;
8
9
using Windows . Foundation . Collections ;
9
10
10
11
namespace Microsoft . Toolkit . Uwp . Input . GazeInteraction
@@ -17,53 +18,58 @@ public class GazeSettingsHelper
17
18
/// <summary>
18
19
/// Retrieves settings as a ValueSet from a shared store.
19
20
/// </summary>
20
- /// <returns>A <see cref="Task "/> representing the asynchronous operation.</returns>
21
- public static async Task RetrieveSharedSettings ( ValueSet settings )
21
+ /// <returns>An <see cref="IAsyncAction "/> representing the asynchronous operation.</returns>
22
+ public static IAsyncAction RetrieveSharedSettings ( ValueSet settings )
22
23
{
23
- // Setup a new app service connection
24
- AppServiceConnection connection = new AppServiceConnection ( ) ;
25
- connection . AppServiceName = "com.microsoft.ectksettings" ;
26
- connection . PackageFamilyName = "Microsoft.EyeControlToolkitSettings_s9y1p3hwd5qda" ;
27
-
28
- // open the connection
29
- var status = await connection . OpenAsync ( ) ;
30
- switch ( status )
24
+ async Task InternalRetrieveSharedSettings ( )
31
25
{
32
- case AppServiceConnectionStatus . Success :
33
- // The new connection opened successfully
34
- // Set up the inputs and send a message to the service
35
- var response = await connection . SendMessageAsync ( new ValueSet ( ) ) ;
26
+ // Setup a new app service connection
27
+ AppServiceConnection connection = new AppServiceConnection ( ) ;
28
+ connection . AppServiceName = "com.microsoft.ectksettings" ;
29
+ connection . PackageFamilyName = "Microsoft.EyeControlToolkitSettings_s9y1p3hwd5qda" ;
36
30
37
- if ( response == null )
38
- {
39
- return ;
40
- }
31
+ // open the connection
32
+ var status = await connection . OpenAsync ( ) ;
33
+ switch ( status )
34
+ {
35
+ case AppServiceConnectionStatus . Success :
36
+ // The new connection opened successfully
37
+ // Set up the inputs and send a message to the service
38
+ var response = await connection . SendMessageAsync ( new ValueSet ( ) ) ;
39
+
40
+ if ( response == null )
41
+ {
42
+ return ;
43
+ }
41
44
42
- switch ( response . Status )
43
- {
44
- case AppServiceResponseStatus . Success :
45
- foreach ( var item in response . Message )
46
- {
47
- settings . Add ( item . Key , item . Value ) ;
48
- }
45
+ switch ( response . Status )
46
+ {
47
+ case AppServiceResponseStatus . Success :
48
+ foreach ( var item in response . Message )
49
+ {
50
+ settings . Add ( item . Key , item . Value ) ;
51
+ }
49
52
50
- break ;
51
- default :
52
- case AppServiceResponseStatus . Failure :
53
- case AppServiceResponseStatus . ResourceLimitsExceeded :
54
- case AppServiceResponseStatus . Unknown :
55
- break ;
56
- }
53
+ break ;
54
+ default :
55
+ case AppServiceResponseStatus . Failure :
56
+ case AppServiceResponseStatus . ResourceLimitsExceeded :
57
+ case AppServiceResponseStatus . Unknown :
58
+ break ;
59
+ }
57
60
58
- break ;
61
+ break ;
59
62
60
- default :
61
- case AppServiceConnectionStatus . AppNotInstalled :
62
- case AppServiceConnectionStatus . AppUnavailable :
63
- case AppServiceConnectionStatus . AppServiceUnavailable :
64
- case AppServiceConnectionStatus . Unknown :
65
- return ;
63
+ default :
64
+ case AppServiceConnectionStatus . AppNotInstalled :
65
+ case AppServiceConnectionStatus . AppUnavailable :
66
+ case AppServiceConnectionStatus . AppServiceUnavailable :
67
+ case AppServiceConnectionStatus . Unknown :
68
+ return ;
69
+ }
66
70
}
71
+
72
+ return InternalRetrieveSharedSettings ( ) . AsAsyncAction ( ) ;
67
73
}
68
74
69
75
private GazeSettingsHelper ( )
0 commit comments