RichTextBox hangs when being clicked on while periodically beingupdated by a background worker

M

Mathias Weyel

Hi Group!

I have a simple GUI featuring a RichTextBox and a Button. On Button
click, I start a BackgroundWorker that performs a query on the database
firing a ProgressChangedEvent for every row. The corresponding event
handler appends the row to the RichTextBox.

This works quite fine, but if I click into the TextBox while the
BackgroundWorker is running, the TextBox gets blank and the GUI hangs
until the BackgroundWorker has finished. As soon as it has, the TextBox
is updated again correctly and everything is fine again. If I don't
click into the TextBox, it does update and display correctly.

There are no event handlers whatsoever attached to the TextBox.

Any ideas?

cheers

Mathias
 
P

Peter Duniho

I have a simple GUI featuring a RichTextBox and a Button. On Button
click, I start a BackgroundWorker that performs a query on the database
firing a ProgressChangedEvent for every row. The corresponding event
handler appends the row to the RichTextBox.

This works quite fine, but if I click into the TextBox while the
BackgroundWorker is running, the TextBox gets blank and the GUI hangs
until the BackgroundWorker has finished.

It sounds as though in your button click handler, you are waiting for the
BackgroundWorker to complete.

If you are, then don't do that.

If you're not, then you should post a concise-but-complete sample of code
that reliably reproduces the problem. There's no way for someone to help
you fix your implementation without knowing what the implementation is.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top