I have two threads t1 and t2. I get information in t1 and based on it I want to call function in t2 which will work in t2.
How can I do it?
Edit:
t2 is thread with c# form. t1 is working in a loop and it gets information that t2 should call function. I think that shared objects won’t work, because t2 doesn’t work in a loop, so I can’t check if some object has changed.
Share the object between both threads (for example a member of a class where both threads run) and access it using the
lockpattern:This ensures object consistency with avoiding both threads interacting with the shared object at the same time.
Another option would be to use a MethodInvoker if one of the threads is a GUI thread for example.