Hello,
I have two classes, one Background class (includes a Thread object), and
one MainForm class. I have information I need to pass from the Background
class to the MainForm class and I am a little confused about the delegate
functionality. I setup my input function (Into the MainForm) as such.....
__delegate void MainFormUIDelegate(MainFormMessage msg);
void Application::MainForm::MainFormWorkerInput(MainFor mMessage msg)
{
Thread *thr;
String *text;
MainFormUIDelegate *uiPtr;
// did the background call us
if (InvokeRequired) {
// setup method invoker
uiPtr = new MainFormUIDelegate(this, &MainForm::MainFormWorkerUpdate);
// invoke the input method on behalf of the background caller
uiPtr->Invoke(msg);
}
}
void Application::MainForm::MainFormWorkerUpdate(MainFo rmMessage msg)
{
Thread *thr = Thread::CurrentThread;
String *text;
// show name of thread
text = String::Format(S"{0}\n", thr->Name);
AppRichTextBox->AppendText(text);
// do we have any text to display
if (msg.hasText()) {
AppRichTextBox->AppendText(msg.Text);
}
}
....The problem is this. I assigned the name "Background" to the
background thread and the name "Main" to the main form thread. When I
output the thread name in the code above, I get the name "Background". Am I
mistaken, or isn't this code (MainFormWorkerUpdate) supposed to be executed
the Main form thread? If so, did I set this up incorrectly?
---
TGF