For the thread that you’re trying to start the GUI element in, you need to set the apartment state of the thread to STA BEFORE you start it.
Example:
myThread.SetApartmentState(ApartmentState.STA);
myThread.Start();
More Related Contents:
- Dispatcher.CurrentDispatcher vs. Application.Current.Dispatcher
- Run code on UI thread in WinRT
- How to pass the UI Dispatcher to the ViewModel
- Where do I get a thread-safe CollectionView?
- The calling thread cannot access this object because a different thread owns it.WPF [duplicate]
- Making sure OnPropertyChanged() is called on UI thread in MVVM WPF app
- Using SynchronizationContext for sending events back to the UI for WinForms or WPF
- Can/Does WPF have multiple GUI threads?
- DispatcherTimer vs a regular Timer in WPF app for a task scheduler
- Ensuring that things run on the UI thread in WPF
- How to prevent a new WPF form from stealing focus?
- In WPF, what are the differences between the x:Name and Name attributes?
- When creating a new GUI, is WPF the preferred choice over Windows Forms? [closed]
- Best way to hide a window from the Alt-Tab program switcher?
- My images are blurry! Why isn’t WPF’s SnapsToDevicePixels working?
- Double-checked locking in .NET
- Making WPF applications look Metro-styled, even in Windows 7? (Window Chrome / Theming / Theme)
- There is no ListBox.SelectionMode=”None”, is there another way to disable selection in a listbox?
- In MVVM model should the model implement INotifyPropertyChanged interface?
- Simple description of worker and I/O threads in .NET
- BitmapImage in WPF does lock file
- Going fullscreen on secondary monitor
- CLIPBRD_E_CANT_OPEN error when setting the Clipboard from .NET
- Binding in a WPF data grid text column
- Change selected and unfocused Listbox style to not be grayed out
- When using PresentationFramework.Aero, do I need to set “Copy Local” to true (and include it in my setup project)?
- Default ContextMenu Style – WPF
- How do I get the UI thread’s Dispatcher?
- Is the CallerMemberName attribute in 4.5 “able to be faked”?
- How to force WPF to use resource URIs that use assembly strong name? Argh!