Urgent multithreading question...
Posted on 1998-12-21
I have a program that uses a richeditview/richeditdoc. I have a toolbar that has buttons on it that will allow the user to start/stop parsing through text in the richeditview. Unfortunately, I have a while loop that processes the text, and the UI is frozen while the 'run' button is pressed, which means it's impossible to press the 'stop' button. I thought an ideal solution to this problem would be to start up a worker thread. I coded another worker thread in, which works in the sense that I can have the second thread pop up message boxes, but the problem is this: I understand it's a no-no to share MFC objecst between threads. Is there some safe way to pass a worker thread a RichEditCtrl Object? In other words, I want to have something like the following:
CRichEditCtrl& theCtrl = GetRichEditCtrl();
and then pass 'theCtrl' to the worker thread, so it can do things with the contents of the RichEdit buffer. Any help is much appreciated.