I got a financial library (com) that call an event each time a price is change. I subscribed to this event and try to update a textbox, but I always get a cross-thread operation. Fine, I use delegate, but it's doesn't work at all... it's freeze the application. My hypothesis is that the event is call to quickly, before the GUI have time to refresh. Any idea how I could deal with that ?
The only way I resolve it for now it to put that :
CheckForIllegalCrossThreadCalls = false;
but I know it's a very bad practice ...
I use .Net 3.5 with c#
EDIT : Delegate code
private delegate void UpdateTextBoxDelegate(String value);
private void UpdateTextBox(String value)
{
this.txtPrice.Text = value;
}
txtPrice.Invoke(new UpdateTextBoxDelegate(UpdateTextBox), price);