-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修复:windows端开启混合模式服务器后无法同步其他客户端的剪贴板(#135)
- Loading branch information
Showing
5 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace SyncClipboard.Core.Interfaces; | ||
|
||
public interface IThreadDispatcher | ||
{ | ||
Task<T> RunOnMainThreadAsync<T>(Func<Task<T>> func); | ||
Task RunOnMainThreadAsync(Func<Task> func); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using CommunityToolkit.WinUI; | ||
using Microsoft.UI.Dispatching; | ||
using SyncClipboard.Core.Interfaces; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace SyncClipboard.WinUI3.Utilities; | ||
|
||
internal class ThreadDispatcher : IThreadDispatcher | ||
{ | ||
private readonly DispatcherQueue _dispatcherQueue; | ||
public ThreadDispatcher(DispatcherQueue dispatcherQueue) | ||
{ | ||
_dispatcherQueue = dispatcherQueue; | ||
} | ||
|
||
public Task<T> RunOnMainThreadAsync<T>(Func<Task<T>> func) | ||
{ | ||
return _dispatcherQueue.EnqueueAsync(func); | ||
} | ||
|
||
public Task RunOnMainThreadAsync(Func<Task> func) | ||
{ | ||
return _dispatcherQueue.EnqueueAsync(func); | ||
} | ||
} |