Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Only the UI thread can access UI elements, which I'm guessing is what those <code>txt</code> things are. <code>Parallel.Invoke</code> is in your case not the UI thread, so the exception is thrown when you try to access the <code>.Text</code> property on the controls.</p> <p>You need to marshal the call across to the UI thread. In WinForms, controls have various ways to help you do this:</p> <pre><code>if (myControl.InvokeRequired) { myControl.Invoke(...); } else { myControl.Text = "something"; } </code></pre> <p>MSDN has an article with examples on it here (VS2010):</p> <p><a href="http://msdn.microsoft.com/en-us/library/757y83z4(v=VS.100).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/757y83z4(v=VS.100).aspx</a></p> <p><strong>Update 1:</strong></p> <p>For WPF the model is similar, but includes the Dispatcher:</p> <pre><code>myControl.Dispatcher.Invoke(...); </code></pre> <ul> <li><a href="http://social.msdn.microsoft.com/Forums/eu/wpf/thread/f4f1242b-f75d-4708-a952-ef667b90c9a7" rel="nofollow">MSDN Forum Post</a></li> <li><a href="http://msdn2.microsoft.com/en-us/library/ms741870.aspx" rel="nofollow">MSDN Article</a></li> </ul> <p><strong>Update 2:</strong> Of course, it looks like you don't even need to use multi-threaded code here. I would guess the overhead of using the multi-threaded portion is more than the code you eventually call. Simply remove the use of multiple threads from this section and set the properties directly:</p> <pre><code> public SettingApp() { InitializeComponent(); SetDataInTextBox(); } private void SetDataInTextBox() { txtIncAns.Text = Properties.Settings.Default.IncludeAN; txtIncAuthor.Text = Properties.Settings.Default.IncludeAutt; txtIncQuo.Text = Properties.Settings.Default.IncludeQU; txtIncSpBegin.Text = Properties.Settings.Default.IncludeSP; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload