Skip to content

Commit

Permalink
feat: Update DispatcherHelper to winui3/release/1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Nov 5, 2023
1 parent bf63591 commit 99e91bd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 98 deletions.
98 changes: 0 additions & 98 deletions src/Uno.UI/Helpers/WinUI/DispatchHelper.cs

This file was deleted.

30 changes: 30 additions & 0 deletions src/Uno.UI/Helpers/WinUI/DispatcherHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
// MUX Reference DispatcherHelper.h, tag winui3/release/1.4.2

using System;
using Windows.UI.Xaml;

namespace Uno.UI.Helpers.WinUI;

internal class DispatcherHelper
{
private Windows.System.DispatcherQueue dispatcherQueue;

public DispatcherHelper(DependencyObject dependencyObject = null)
{
dispatcherQueue = Windows.System.DispatcherQueue.GetForCurrentThread();
}

public void RunAsync(Action func, bool fallbackToThisThread = false)
{
var result = dispatcherQueue?.TryEnqueue(() => func()) ?? false;
if (!result)
{
if (fallbackToThisThread)
{
func();
}
}
}
}

0 comments on commit 99e91bd

Please sign in to comment.