I have a form receiving asynchronous callbacks from an object on random worker threads. I pass data to my main thread using delegates like in the snippet below and I use it to update onscreen controls. But, the performance is so bad that upon reaching 500 updates per second, my entire program gets locked up. And, I'm sure that it's not my GUI processing causing this problem because I can simulate a similar level of update within my form without any problems at all. Do I need to be using a better process for handing off data from one thread to another?
delegate void DStatus( MyStatus obj );
DStatus _status; // set to MainThreadOnStatus during construction
// this function only called on form's owner thread
void MainThreadOnStatus( MyStatus obj )
{
// screen updates here as needed
}
// this function called by arbitrary worker threads in external facility
void OnStatus( MyStatus obj )
{
this.BeginInvoke( _status, obj );
}