RichTextBox multithreading

  • Thread starter Thread starter lizii
  • Start date Start date
L

lizii

At the moment i am trying to write into a richtextbox using the Rtf
call from another richtextbox.

However realising that richtextbox do not have multithreading - i know
i need to invoke this item and make it multithreaded safe. But i
cannot find a single good example of how to do this. The richtextbox
i am trying to update is on one form - the richtextbox which has the
information to update it with is on another. I understand that i need
to invoke the control which i am updating...but i am just a little
confused.


Can someone give a rough example or point me at a source which makes
this all clear?


Thanks folks!


Liz.
 
You haven't described how you are multithreading. If you have two forms in
your app, by default you don't have more than one thread.
 
Just discovered the reason why this is happening and maybe a better
explanation.


I have a class which creates my own personally designed messagebox and
sets up a few variables.

I have an application which can consist of 2-5 forms - which with
there own closing method which calls said messagebox class on closing
to pop up a box which asks the user to confirm closing.

however - this messagebox has another function - called displaylog -
which is used to display a richtextbox with a list of log messages.

also in that function is a reference to:

thisrichtextbox->Rtf = anotherform->Richtextbox->Rtf;

this then causes a problem - when you close all those forms together -
each form creates its own messagebox - it makes a call to that line.
This then causes threading problems with that line referring to
writing to anotherform's richtextbox.

simplest solution? Sort out my constructor and remove that botch job
- or place a criticalsection around that call or a hybrid of the two.
 
Back
Top