run get on ui thread
MODIFY
src/Directory.Build.props
src/Directory.Build.props
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
- <Version>2.0.0-beta.1</Version>
+ <Version>2.0.0-beta.2</Version>
<PackageTags>Clipboard, Copy</PackageTags>
<Description>A netstandard package to copy text to the clipboard.</Description>
</PropertyGroup>

MODIFY
src/TextCopy/Clipboard_GetUap.cs
src/TextCopy/Clipboard_GetUap.cs
@@ -3,6 +3,8 @@ using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.DataTransfer;
using UapClipboard = Windows.ApplicationModel.DataTransfer.Clipboard;
+using Windows.ApplicationModel.Core;
+using Windows.UI.Core;
namespace TextCopy
{
@@ -14,12 +16,18 @@ namespace TextCopy
{
var dataPackageView = UapClipboard.GetContent();
+ var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
+ string? value = null;
+ await dispatcher.RunAsync(CoreDispatcherPriority.Normal,
+ async () => {
+
if (dataPackageView.Contains(StandardDataFormats.Text))
{
- return await dataPackageView.GetTextAsync();
+ value = await dataPackageView.GetTextAsync();
+ return;
}
-
- return null;
+ });
+ return value;
};
}
}

MODIFY
src/UapApp/UapApp.csproj
src/UapApp/UapApp.csproj
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
- <Compile Include="Properties\AssemblyInfo.cs" />
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>

run get on ui thread