Hi
I have a multi threading application, in which I am trying to use UI/Main thread to display data.
Here is what I am doing
1. I am getting quote from an API in a thread (each time a new thread is created)
2. I am going to main thread using "If Me.InvokeRequired"
3. Display information on screen
4. Create a new thread for further processing
I can further explain this with code.
I am also getting the error "A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll"
I am unable to find why I am not able to get UI thread though I am using the following code to check the UI. It some time works and some time it does not work. Some time it goes to UI thread with invoke and sometime it does take the condition and comes to display function with worker thread.
The code is as follow (This is a cut down version)
If Me.InvokeRequired Then
Dim d As New SetQuoteTempCallback(AddressOf SetQuoteTemp)
Me.BeginInvoke(d, New Object() {[symbol_id], [bidprice], [askprice]})
Else
displaySymbolInfoOnChart(symbol_id, bidprice, askprice)
end if
Sara