How can I use class System.Windows.Threading.Dispatcher from within a .Net 5.0 app?
According to the online documentation, it should be available.
https://learn.microsoft.com/en-us/dotnet/api/system.windows.threading.dispatcher?view=net-5.0.
Normally, in a .Net Framework app, I would just add a reference to assembly WindowsBase.dll. But since I'm using a .Net 5.0 project I can only reference Nuget Packages.
Cannot add assemblies to .Net Core application in Visual Studio 2019.
However, there does not seem to be a WindowsBase Nuget package.
https://www.nuget.org/packages?q=WindowsBase.
There is a package called Microsoft.Windows.Compatibility which according to its descriptions sounds like it should include the class; but it does not.
https://www.nuget.org/packages/Microsoft.Windows.Compatibility/6.0.0-preview.5.21301.5
Any suggestions?
Restrictions:
- The project uses WinForms extensively. It's not viable to convert it to WPF.
- The reason I use Dispatcher, it so that objects on different threads can call modifications to the UI. The UI does not exist when these objects are created, so passing controls to them is not an option (also, not very elegant IMO for business objects to know about buttons and stuff).