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