Skip to content

Commit 6119b93

Browse files
committed
Changing back GazeSettingsHelper.RetrieveSharedSettings to return IAsyncAction, to keep this from being a breaking change.
1 parent 19722d8 commit 6119b93

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

Microsoft.Toolkit.Uwp.Input.GazeInteraction/GazeSettingsHelper.cs

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Threading.Tasks;
77
using Windows.ApplicationModel.AppService;
8+
using Windows.Foundation;
89
using Windows.Foundation.Collections;
910

1011
namespace Microsoft.Toolkit.Uwp.Input.GazeInteraction
@@ -17,53 +18,58 @@ public class GazeSettingsHelper
1718
/// <summary>
1819
/// Retrieves settings as a ValueSet from a shared store.
1920
/// </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)
2223
{
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()
3125
{
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";
3630

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+
}
4144

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+
}
4952

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+
}
5760

58-
break;
61+
break;
5962

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+
}
6670
}
71+
72+
return InternalRetrieveSharedSettings().AsAsyncAction();
6773
}
6874

6975
private GazeSettingsHelper()

0 commit comments

Comments
 (0)