Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

To make my form responsible, I use a 2nd thread to do a process.

If I try to get the text of a combo box on a form from within the thread, I get cross thread... exception.

That is normal, because combo box on the form is for another thread.

So I store the value of ComboBox.Text into a string variable and use that string in my thread and it works.

 

One thing is strange here:

When I try to get the checked value of radio button directly from within thread it works fine and I receive no exception.

 

> It means that I should continue to do what I do? OR it just works and is not recommended and I should the same as I do for combo box for radio button also?

(This applies to some other controls also)

 

Thanks :)

  • Leaders
Posted
I'm not particularly experienced with multi-threading, but my understanding is that one should not interact directly with the UI from secondary threads. Caching values before invoking the thread or obtaining the values via the Invoke method would probably be the way to go.
[sIGPIC]e[/sIGPIC]
Posted

I haven't had any problems like that either. Are you monitoring the combobox in the thread for a change? and when you select something else, this is when you get the error?

 

Before you start the thread. you may want to try and set "isBackground = true" for that thread.

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...