[Launcher] Fix Copying of calculator value (#2929)

This commit is contained in:
Tomas Agustin Raies 2020-05-12 16:41:49 -07:00 committed by GitHub
parent ce96e34d25
commit 688fefc4dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
using Mages.Core;
using Wox.Plugin;
@ -56,16 +57,23 @@ namespace Microsoft.Plugin.Caculator
SubTitle = Context.API.GetTranslation("wox_plugin_calculator_copy_number_to_clipboard"),
Action = c =>
{
try
var ret = false;
var thread = new Thread(() =>
{
Clipboard.SetText(result.ToString());
return true;
}
catch (ExternalException)
{
MessageBox.Show("Copy failed, please try later");
return false;
}
try
{
Clipboard.SetText(result.ToString());
ret = true;
}
catch (ExternalException)
{
MessageBox.Show("Copy failed, please try later");
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
return ret;
}
}
};