Skip to content

Commit

Permalink
feat(dragdrop): Fix WASM support of Drag and drop
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Oct 16, 2020
1 parent 0e3db7a commit c4cb3a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/Uno.UI/UI/Xaml/DragDropManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ public DragDropManager(Window window)
/// <inheritdoc />
public void BeginDragAndDrop(CoreDragInfo info, ICoreDropOperationTarget? target = null)
{
if (!_window.Dispatcher.HasThreadAccess)
if (
#if __WASM__
_window.Dispatcher.IsThreadingSupported &&
#endif
!_window.Dispatcher.HasThreadAccess)
{
_window.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => BeginDragAndDrop(info, target));
return;
Expand Down
9 changes: 5 additions & 4 deletions src/Uno.UWP/UI/Core/CoreDispatcher.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace Windows.UI.Core
{
public sealed partial class CoreDispatcher
{
private readonly bool ThreadingSupported = Environment.GetEnvironmentVariable("UNO_BOOTSTRAP_MONO_RUNTIME_CONFIGURATION").StartsWith("threads", StringComparison.OrdinalIgnoreCase);
internal bool IsThreadingSupported { get; } = Environment.GetEnvironmentVariable("UNO_BOOTSTRAP_MONO_RUNTIME_CONFIGURATION").StartsWith("threads", StringComparison.OrdinalIgnoreCase);

private Timer _backgroundWakeupTimer;

/// <summary>
Expand All @@ -31,7 +32,7 @@ private static int DispatcherCallback()

partial void Initialize()
{
if (ThreadingSupported)
if (IsThreadingSupported)
{
if(Thread.CurrentThread.ManagedThreadId != 1)
{
Expand All @@ -48,7 +49,7 @@ partial void Initialize()

private bool GetHasThreadAccess()
{
if (ThreadingSupported)
if (IsThreadingSupported)
{
return Thread.CurrentThread.ManagedThreadId == 1;
}
Expand All @@ -64,7 +65,7 @@ partial void EnqueueNative()
{
if (DispatchOverride == null)
{
if (!ThreadingSupported)
if (!IsThreadingSupported)
{
WebAssemblyRuntime.InvokeJSUnmarshalled("CoreDispatcher:WakeUp", IntPtr.Zero);
}
Expand Down

0 comments on commit c4cb3a7

Please sign in to comment.