WPFCustomMessageBox icon indicating copy to clipboard operation
WPFCustomMessageBox copied to clipboard

Query in Thread

Open ArshadKather opened this issue 2 years ago • 1 comments

Can you explain why we need to invoke Message Box in STA. I'm trying to re-create your code for learning purpose.

ArshadKather avatar Feb 09 '23 11:02 ArshadKather

Hello @ArshadKather, Sorry for the late reply! In general most WPF elements are only accessible from a single thread and must not be accessed from multiple different threads in parallel. Because of this we have to ensure that the thread that creates and shows the WPF message box is in the single threaded apartment. A better explanation can be found here: https://stackoverflow.com/questions/2329978/the-calling-thread-must-be-sta-because-many-ui-components-require-this

Kind regards,

kcl93

kcl93 avatar May 15 '23 05:05 kcl93