This commit is contained in:
Aaron-Junker 2021-11-25 19:48:24 +01:00
parent 24df19e44b
commit b462a510b3
2 changed files with 3 additions and 2 deletions

View file

@ -1,6 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading;
using Common; using Common;
using PreviewHandlerCommon; using PreviewHandlerCommon;
@ -24,7 +25,7 @@ namespace MonacoPreviewHandler
[STAThread] [STAThread]
public override void DoPreview() public override void DoPreview()
{ {
Thread.CurrentThread.SetApartmentState(ApartmentState.STA);
_monacoPreviewHandlerControl.DoPreview(FilePath); _monacoPreviewHandlerControl.DoPreview(FilePath);
} }

View file

@ -42,7 +42,7 @@ namespace MonacoPreviewHandler
public override void DoPreview<T>(T dataSource) public override void DoPreview<T>(T dataSource)
{ {
Thread.CurrentThread.SetApartmentState(ApartmentState.STA);
if (!(dataSource is string filePath)) if (!(dataSource is string filePath))
{ {
throw new ArgumentException($"{nameof(dataSource)} for {nameof(MonacoPreviewHandler)} must be a string but was a '{typeof(T)}'"); throw new ArgumentException($"{nameof(dataSource)} for {nameof(MonacoPreviewHandler)} must be a string but was a '{typeof(T)}'");