Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I have a form, with a multiline textbox, and I have a background worker, which handles a connection to an IRC server.

 

But how can I add text to my textbox from my background worker?

 

Thanks in advance :)

Posted

Well I'll admit that I'd never heard of a BackgroundWorker, however after looking up the class I'm not convinced you need to use one. That being said the MSDN library states....

 

"You must be careful not to manipulate any user-interface objects in your DoWork event handler. Instead, communicate to the user interface through the ProgressChanged and RunWorkerCompleted events."

 

This would seem to indicate you need to use the ProgressChanged event.

 

http://msdn2.microsoft.com/en-US/library/system.componentmodel.backgroundworker.aspx

Anybody looking for a graduate programmer (Midlands, England)?
Posted (edited)

Are you using the .Net 2.0 Background Worker Control?

 

Basically, the way that control works is you impliment three event handlers for three basic events the background worker raises, DoWork, ProgressChanged, and RunWorkerCompleted and communicate with the controls in the main thread from those event handlers.

 

There are other methods you can use involving delegates, but if you are able to handle the updates in the ProgressChanged event handler, then you won't need to use them.

 

Edit:

And cags beat me to the punch! :) I have used the background worker and it made a lot of really complicated stuff that I was doing in 1.1 very easy when I ported the code to 2.0. It won't work in all situations, but when you can use it, it makes everything a lot easier.

Edited by mskeel

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...