i am using c#.net framework 4.5 using the sample when i init ticker, it shows ticks in debug window. But when I try to access its value to display to a form or something, it gives error... Error: Error while recieving data. Message: The calling thread cannot access this object because a different thread owns it.
i tried to call a delegate ontick event but still the problem remains same.
main thing is i am calling ticker from from gives this error, or when i call a delegate and points to form, gives error. BUT when i call to print in debug window, it prints well. what is the matter? let me know
{
Debug.WriteLine("T: Tick " + Utils.JsonSerialize(TickData));
Tick t = TickData;
decimal a = t.LastPrice;
decimal b = t.AveragePrice;
txt.Text = a + " " + b;
}
from above code, when i use debug.writeline, it works good.
but when i try to get result in textbox or anywhere, it gives error. why ?
your calling "txt" from another thread,assume,you were using windows forms ," txt " belongs to UI thread ,you need to use like