Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.Extensions;
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.Advertisement;
using Windows.Devices.Enumeration;
Expand Down Expand Up @@ -197,7 +197,7 @@ private async Task Init()
/// <param name="args">The advertisement.</param>
private async void AdvertisementWatcher_Received(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs args)
{
await DispatcherQueue.ExecuteOnUIThreadAsync(
await DispatcherQueue.EnqueueAsync(
() =>
{
if (_readerWriterLockSlim.TryEnterReadLock(TimeSpan.FromSeconds(1)))
Expand Down Expand Up @@ -281,7 +281,7 @@ private async void DeviceWatcher_Removed(DeviceWatcher sender, DeviceInformation
// Protect against race condition if the task runs after the app stopped the deviceWatcher.
if (sender == _deviceWatcher)
{
await DispatcherQueue.ExecuteOnUIThreadAsync(
await DispatcherQueue.EnqueueAsync(
() =>
{
if (_readerWriterLockSlim.TryEnterWriteLock(TimeSpan.FromSeconds(1)))
Expand Down Expand Up @@ -331,7 +331,7 @@ private async Task AddDeviceToList(DeviceInformation deviceInfo)

if (connectable)
{
await DispatcherQueue.ExecuteOnUIThreadAsync(
await DispatcherQueue.EnqueueAsync(
() =>
{
if (_readerWriterLockSlim.TryEnterWriteLock(TimeSpan.FromSeconds(1)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.Extensions;
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.GenericAttributeProfile;
using Windows.Devices.Enumeration;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.Xaml.Media.Imaging;

namespace Microsoft.Toolkit.Uwp.Connectivity
Expand Down Expand Up @@ -404,7 +403,7 @@ private void ObservableBluetoothLEDevice_PropertyChanged(object sender, Property
/// <exception cref="Exception">Throws Exception when no permission to access device</exception>
public async Task ConnectAsync()
{
await DispatcherQueue.ExecuteOnUIThreadAsync(
await DispatcherQueue.EnqueueAsync(
async () =>
{
if (BluetoothLEDevice == null)
Expand Down Expand Up @@ -478,7 +477,7 @@ public async Task DoInAppPairingAsync()
/// <returns>The task of the update.</returns>
public async Task UpdateAsync(DeviceInformationUpdate deviceUpdate)
{
await DispatcherQueue.ExecuteOnUIThreadAsync(
await DispatcherQueue.EnqueueAsync(
() =>
{
DeviceInfo.Update(deviceUpdate);
Expand Down Expand Up @@ -521,7 +520,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
/// <param name="args">The arguments.</param>
private async void BluetoothLEDevice_NameChanged(BluetoothLEDevice sender, object args)
{
await DispatcherQueue.ExecuteOnUIThreadAsync(() => { Name = BluetoothLEDevice.Name; }, DispatcherQueuePriority.Normal);
await DispatcherQueue.EnqueueAsync(() => { Name = BluetoothLEDevice.Name; }, DispatcherQueuePriority.Normal);
}

/// <summary>
Expand All @@ -531,7 +530,7 @@ private async void BluetoothLEDevice_NameChanged(BluetoothLEDevice sender, objec
/// <param name="args">The arguments.</param>
private async void BluetoothLEDevice_ConnectionStatusChanged(BluetoothLEDevice sender, object args)
{
await DispatcherQueue.ExecuteOnUIThreadAsync(
await DispatcherQueue.EnqueueAsync(
() =>
{
IsPaired = DeviceInfo.Pairing.IsPaired;
Expand All @@ -544,7 +543,7 @@ await DispatcherQueue.ExecuteOnUIThreadAsync(
/// </summary>
private async void LoadGlyph()
{
await DispatcherQueue.ExecuteOnUIThreadAsync(
await DispatcherQueue.EnqueueAsync(
async () =>
{
var deviceThumbnail = await DeviceInfo.GetGlyphThumbnailAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.Extensions;
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.GenericAttributeProfile;
using Windows.Security.Cryptography;
Expand Down Expand Up @@ -469,7 +469,7 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
/// <param name="args">The <see cref="GattValueChangedEventArgs"/> instance containing the event data.</param>
private async void Characteristic_ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
{
await DispatcherQueue.ExecuteOnUIThreadAsync(() => { SetValue(args.CharacteristicValue); }, DispatcherQueuePriority.Normal);
await DispatcherQueue.EnqueueAsync(() => { SetValue(args.CharacteristicValue); }, DispatcherQueuePriority.Normal);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Toolkit.Uwp.Helpers;
using Windows.System;
using Windows.UI.Xaml;
using Microsoft.Toolkit.Uwp.Extensions;

namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
Expand All @@ -21,7 +22,7 @@ private async void ExecuteFromDifferentThreadButton_Click(object sender, RoutedE
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
int crossThreadReturnedValue = await Task.Run<int>(async () =>
{
int returnedFromUIThread = await dispatcherQueue.ExecuteOnUIThreadAsync<int>(() =>
int returnedFromUIThread = await dispatcherQueue.EnqueueAsync<int>(() =>
{
NormalTextBlock.Text = "Updated from a random thread!";
return 1;
Expand Down
5 changes: 2 additions & 3 deletions Microsoft.Toolkit.Uwp.UI/Cache/ImageCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.Extensions;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.System;
using Windows.UI.Xaml.Media.Imaging;

Expand Down Expand Up @@ -63,7 +62,7 @@ protected override async Task<BitmapImage> InitializeTypeAsync(Stream stream, Li
throw new FileNotFoundException();
}

return await DispatcherQueue.ExecuteOnUIThreadAsync(async () =>
return await DispatcherQueue.EnqueueAsync(async () =>
{
BitmapImage image = new BitmapImage();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

using System;
using System.Threading;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.Extensions;
using Windows.Devices.Input;
using Windows.Foundation;
using Windows.System;
Expand Down Expand Up @@ -369,7 +369,7 @@ private static bool IsCursorResourceAvailable()

private static async void RunInUIThread(DispatcherQueue dispatcherQueue, Action action)
{
await dispatcherQueue.ExecuteOnUIThreadAsync(action, DispatcherQueuePriority.Normal);
await dispatcherQueue.EnqueueAsync(action, DispatcherQueuePriority.Normal);
}
}
}
11 changes: 5 additions & 6 deletions Microsoft.Toolkit.Uwp.UI/Helpers/ThemeListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.Extensions;
using Windows.Foundation.Metadata;
using Windows.System;
using Windows.UI.ViewManagement;
Expand Down Expand Up @@ -84,7 +83,7 @@ public ThemeListener(DispatcherQueue dispatcherQueue = null)
private void Accessible_HighContrastChanged(AccessibilitySettings sender, object args)
{
#if DEBUG
Debug.WriteLine("HighContrast Changed");
System.Diagnostics.Debug.WriteLine("HighContrast Changed");
#endif

UpdateProperties();
Expand All @@ -100,15 +99,15 @@ private async void Settings_ColorValuesChanged(UISettings sender, object args)
internal Task OnColorValuesChanged()
{
// Getting called off thread, so we need to dispatch to request value.
return DispatcherQueue.ExecuteOnUIThreadAsync(
return DispatcherQueue.EnqueueAsync(
() =>
{
// TODO: This doesn't stop the multiple calls if we're in our faked 'White' HighContrast Mode below.
if (CurrentTheme != Application.Current.RequestedTheme ||
IsHighContrast != _accessible.HighContrast)
{
#if DEBUG
Debug.WriteLine("Color Values Changed");
System.Diagnostics.Debug.WriteLine("Color Values Changed");
#endif

UpdateProperties();
Expand All @@ -122,7 +121,7 @@ private void CoreWindow_Activated(Windows.UI.Core.CoreWindow sender, Windows.UI.
IsHighContrast != _accessible.HighContrast)
{
#if DEBUG
Debug.WriteLine("CoreWindow Activated Changed");
System.Diagnostics.Debug.WriteLine("CoreWindow Activated Changed");
#endif

UpdateProperties();
Expand Down
2 changes: 0 additions & 2 deletions Microsoft.Toolkit.Uwp/Deferred/EventDeferral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

Expand Down
Loading