I need code which will process messages I grab from a control within a chat window (a RichEdit control). The code needs to monitor the control and copy text meeting certain criteria (e.g. with certain usernames in the line).
One hitch, the control exists outside the scope of my C# program. I am "spying" on a process in a separate chat program to be able to pluck out the data from the RichEdit control. Because of this I don't think I would be able to access the event model (e.g. Change event) of the foreign application, instead I need to read the control (using SendMessage along with EM_GETLINE and others), load the data into a StringCollection or other object within the scope of my C# app, and then process the data.
Would it be best to use a WHILE loop, within which I constantly poll the RichEdit control for new messages, and only act if a new message arrives that needs to be processed? Or is there some other way?