The apartment state of the current thread

Bug reports.
omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

The apartment state of the current thread

Post by omayer » Fri Dec 23, 2011 4:57 am

Why I am getting this warning - code module, 3.2 - The apartment state of the current thread is not set to STA. Please make sure that all threads accessing Ranorex methods have their apartment state set to STA.
warn.jpg
warn.jpg (29.16 KiB) Viewed 2653 times
Tipu

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: The apartment state of the current thread

Post by omayer » Fri Dec 23, 2011 5:02 am

ok, if i commented out this code then no warning -

/*****Check for any popup, click OK and terminate the test*********/
// Thread dialogWatchers = new Thread(rmaxValidation.WindowsPopUp);
// dialogWatchers.IsBackground = true;
// dialogWatchers.Start();

not sure why getting the warning
Tipu

omayer
Posts: 458
Joined: Thu Oct 28, 2010 6:14 pm

Re: The apartment state of the current thread

Post by omayer » Fri Dec 23, 2011 5:05 am

ok problem solved.. i have to run one testcase then dialogwatcher that stopped the warning, wonder why is that warning
Tipu

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: The apartment state of the current thread

Post by Support Team » Fri Dec 23, 2011 10:07 am

You have to set the apartment state for every new thread to STA, otherwise identification capabilities of Ranorex may be limited:
Thread dialogWatchers = new Thread(rmaxValidation.WindowsPopUp);
dialogWatchers.IsBackground = true;
dialogWatcher.SetApartmentState(ApartmentState.STA);
dialogWatchers.Start();
Regards,
Alex
Ranorex Team
.
Image