mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-29 17:02:05 +13:00
fixed #6731: Run PinToScreenForm inside separate thread
This commit is contained in:
parent
744f844f9c
commit
cab9a5a57f
2 changed files with 25 additions and 3 deletions
|
@ -1319,8 +1319,7 @@ public static void PinToScreen(Image image, Point? location = null)
|
|||
PinToScreenOptions options = new PinToScreenOptions();
|
||||
options.BackgroundColor = ShareXResources.Theme.LightBackgroundColor;
|
||||
|
||||
PinToScreenForm form = new PinToScreenForm(image, options, location);
|
||||
form.Show();
|
||||
PinToScreenForm.PinToScreenAsync(image, options, location);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX
|
||||
|
@ -128,7 +129,7 @@ private PinToScreenForm(PinToScreenOptions options)
|
|||
loaded = true;
|
||||
}
|
||||
|
||||
public PinToScreenForm(Image image, PinToScreenOptions options, Point? location = null) : this(options)
|
||||
private PinToScreenForm(Image image, PinToScreenOptions options, Point? location = null) : this(options)
|
||||
{
|
||||
Image = image;
|
||||
AutoSizeForm();
|
||||
|
@ -144,6 +145,28 @@ public PinToScreenForm(Image image, PinToScreenOptions options, Point? location
|
|||
}
|
||||
}
|
||||
|
||||
public static void PinToScreenAsync(Image image, PinToScreenOptions options = null, Point? location = null)
|
||||
{
|
||||
if (image != null)
|
||||
{
|
||||
if (options == null)
|
||||
{
|
||||
options = new PinToScreenOptions();
|
||||
}
|
||||
|
||||
Thread thread = new Thread(() =>
|
||||
{
|
||||
using (PinToScreenForm form = new PinToScreenForm(image, options, location))
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
});
|
||||
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
|
|
Loading…
Reference in a new issue