Forum Migration Notice
Update (2026-01-21): The user forums are now in read-only mode pending the data migration.

Update (2026-01-12): The user forums will be put into read-only mode on the 21st of January, 00:00 CET, to prepare for the data migration.

We're transitioning to a more modern community platform by beginning of next year. Learn about the upcoming changes and what to expect.

MTA threads in WPF app (STA) not working?

I recently ran into an issue calling certain functions in the ABB PC SDK from a WPF application.  I will try and explain here.

WPF applications run as STAThread...this cannot be changed.  About a month ago we had an issue when certain methods in the PC SDK were called from a NEW thread within the main STA thread.  This was resolved by starting the thread as MTA:

Thread t = new Thread(new ParameterizedThreadStart(StartThread));
t.SetApartmentState(ApartmentState.MTA);

But something has changed suddenly (perhaps with a Microsoft update?) that prevents this from working.  It's as if the MTA thread really is an STA thread, even though it tells you otherwise.

From what I can tell, the ONLY way I can get these certain functions in the PC SDK to work when run from a couple threads deep is to make sure the main application thread is MTA.  If I start out as STA, I cannot create MTA threads that work with the PC SDK.  If I start MTA everything works fine.  If I start as MTA and create STA threads everything breaks again.

This is a problem for an application written in WPF that must be STA.

The functions I'm using that throw a generic System.Exeception with information are:
RapidDataType.GetComponents();
RapidData.ReadItem(i, j);

Any ideas on where to go from here?

Thanks,
Dan