Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:42:06+00:00 2026-06-01T23:42:06+00:00

Referencing this FsEye issue, how can I use reflection to determine whether an object

  • 0

Referencing this FsEye issue, how can I use reflection to determine whether an object needs its members (or indeed a specific member if possible) to be invoked on the GUI thread?

The scenario is this: a user creates an instance of a WebBrowser object within FSI (which runs its own WinForms event loop), then they attempt to expand the node in FsEye. But that results in an unhandled exception dialog box warning that

System.Threading.ThreadStateException: Current thread must be set to
single thread apartment (STA) mode before OLE calls can be made.
Ensure that your Main function has STAThreadAttribute marked on it.

(specifically this appears to occur when loading the AccessibilityObject property only).

I know this is because FsEye loads child nodes lazily, asynchronously, and in parallel using F# async computation expression with Async.Parallel and thus is invoking members of this OLE object from non-original, non-STA (i.e. not the original FSI GUI thread) thread pool threads. I also know how to fix this by switching to the GUI thread context within my async expressions, but I would only like to do that when absolutely necessary.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:42:07+00:00Added an answer on June 1, 2026 at 11:42 pm

    There is no single member you can look at to determine if an object needs to be invoked from a STA / main thread of the application. It’s just something that is inherent in the contract of an individual type

    That being said there are certain clues you can look for. These would indicate an object is a UI bound component but by no means is this a definitive list

    • Derives from System.Windows.Forms.Control
    • Derives from UIElement
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Referencing this Fiddle ( http://jsfiddle.net/j5uGN ), how can I toggle a clicked image's border
Referencing this answer to a question. Can this be rewritten as: private static BinaryFormatter
Referencing this question: System.Reflection.Assembly.LoadFile Locks File System.IO.File.ReadAllBytes(path) wont work since it's not a standalone
I'm having difficulty referencing this from within a javascript inline function, within an object
Referencing this post: ruby on rails average per day I'm getting the average per
Having issues referencing $(this) from within a the nested ajax 'success' function... I know
Referencing Is Facebook an OpenID provider? here. This is kind of an additional question
In forward referencing language such as c#, how does the compiler handle this? What
I am currently referencing this website for AD role management. The C# code is
I have made this mistake several times, and found myself referencing This Post every

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.