Bug 447847 - Investigate potential threading issues
Summary: Investigate potential threading issues
Status: NEW
Alias: None
Product: UI Automation
Classification: Mono
Component: Winforms - UIA (show other bugs)
Version: Release 1.0
Hardware: Other Other
: P4 - Low : Normal
Target Milestone: ---
Assignee: E-mail List
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-21 21:39 UTC by Brad Taylor
Modified: 2009-03-04 16:11 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brad Taylor 2008-11-21 21:39:12 UTC
Winforms Providers can be constructed in a different thread from the Winforms thread, so our code needs to deal with this condition.  Please research the issue to develop a test case, a detailed description, some possible solutions, and a time estimate for it's completion (if it's more than the allotted hours on this issue).
Comment 1 Sanford Armstrong 2008-11-21 22:09:35 UTC
Quick comment: we cover this to some aspect by checking Control.InvokeRequired, then using Control.BeginInvoke to modify the controls as necessary.  Some things to look at:

* Are we using *Invoke* stuff everywhere we need to be?
* How are we testing this?
* When we use BeginInvoke, do we need to wait on the delegate to return? That is, do we move on, expecting the control to be modified when it might not yet have been?
* What other issues lurk?
Comment 2 Sanford Armstrong 2008-12-12 14:43:07 UTC
Quick update:

* I believe we are using BeginInvoke everywhere we need to at this time
* QA's samples are the only real way of testing this, often enough.
* We use BeginInvoke instead of Invoke because we can't wait on the delegate to return...often the action we take in BeginInvoke will raise events that need to be handled back on our thread, and so we can't be waiting for the delegate to return or we get deadlock.
* Potential issue, untested: Because of using BeginInvoke, it seems possible that you could do provider.Select() and then immediately after check provider.IsSelected, and if there's any delay on the delegate then IsSelected would still return the old value.
* BIG ISSUE: We cannot allow *any* exceptions to occur in the delegate.  Unhandled exceptions in a BeginInvoke delegate go to the applications untrapped exception handler, and it's really messy and can be assumed to cause the app to crash.  So if we need to do checks and possibly raise exceptions, we need to do that in our thread *before* BeginInvoke.  We should keep our BeginInvoke delegates simple, do lots of checks before the BeginInvoke, and maybe even the entire body of each delegate in a try/catch that outputs exceptions so we can see them, even though we can't really handle them (since we can't wait for the delegate to return, etc etc).

I looked through all of our BeginInvoke calls and after a few fixes I don't see any place where I'd expect exceptions to occur in our delegates, but of course it's always possible so I think we should do the try/catch.