forked from codecadwallader/codemaid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cleanup external files issue codecadwallader#748
- Loading branch information
heku
committed
Nov 7, 2021
1 parent
220a94d
commit fa96ee9
Showing
5 changed files
with
53 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.VisualStudio.Shell; | ||
using System; | ||
|
||
namespace SteveCadwallader.CodeMaid.Helpers | ||
{ | ||
internal static class UIThread | ||
{ | ||
public static void Run(Action action) | ||
{ | ||
if (ThreadHelper.CheckAccess()) | ||
{ | ||
action(); | ||
} | ||
ThreadHelper.JoinableTaskFactory.Run(async () => | ||
{ | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
action(); | ||
}); | ||
} | ||
|
||
public static T Run<T>(Func<T> func) | ||
{ | ||
if (ThreadHelper.CheckAccess()) | ||
{ | ||
return func(); | ||
} | ||
return ThreadHelper.JoinableTaskFactory.Run(async () => | ||
{ | ||
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
return func(); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters