Windows Develop Bookmark and Share   
 index > Windows Forms General > System::Windows::Forms::Control::Invoke();
 

System::Windows::Forms::Control::Invoke();

I have a BackgroundWorker that listens for incoming connection requests via a Tcp Socket. When the client socket connects I need to update one of my controls. I need to do this inside the thread, which in return means I need to invoke the control I need to update. The problem is no matter what I do I can't get my delegate/functions to work. Here is what I have:


// FormServer.h
private: delegate void AddClientToList();

// Engine_Listener.cpp
listViewClients->Invoke(FormServer::AddClientToList);

// Processor_ListView.cpp
void FormServer::AddClientToList()
{
}


I have even tried the example on MSDN and it would not work. If someone can show me (in detail and as simple as possible) how to properly invoke a control, I would really appreciate it.

Thank you if you help.
Dave.
Ðãvę Âņđęŕŝőŋ1  Sunday, February 18, 2007 4:04 AM
I got it to work.


// FormServer.h
private: delegate void AddClientToListDelegate();
private: void AddClientToList();

// Engine_Listener.cpp
AddClientToListDelegate ^AddClientToListDelegateB = gcnew AddClientToListDelegate(this, &FormServer::AddClientToList);
listViewClients->Invoke(AddClientToListDelegateB);

// Processor_ListView.cpp
void FormServer::AddClientToList()
{
}

Ðãvę Âņđęŕŝőŋ1  Sunday, February 18, 2007 5:11 AM
I got it to work.


// FormServer.h
private: delegate void AddClientToListDelegate();
private: void AddClientToList();

// Engine_Listener.cpp
AddClientToListDelegate ^AddClientToListDelegateB = gcnew AddClientToListDelegate(this, &FormServer::AddClientToList);
listViewClients->Invoke(AddClientToListDelegateB);

// Processor_ListView.cpp
void FormServer::AddClientToList()
{
}

Ðãvę Âņđęŕŝőŋ1  Sunday, February 18, 2007 5:11 AM

You can use google to search for other answers

Custom Search

More Threads

• Obtain calling application name in class library
• gurus, what does "Principal" or "CustomPrincipal" mean to you?
• "dll not found" using VB6sp5 windows xp
• me.name
• Comparing tables and then adding the differences from winform application
• opening swf file in (Ax)WebBrowser from netwok fails
• c# ooc problem
• code access security
• Synchronize unique custom BackgroundWorker, BackgroundWorkers
• How to find start of line in richtextbox