The problem of passing
anything to/from a thread from/to another thread are easily solved by using a proper thread wrapper. Please see my past answers:
How to pass ref parameter to the thread[
^],
Change parameters of thread (producer) after it is started[
^],
MultiThreading in C#[
^].
Can you see the idea? First, you obtain access to the whole instance of the wrapper class from the thread method, because you actually pass the whole reference to the instance, "this", without a need for typecasting. Secondly, you can properly encapsulate the access to the wrapper instance from the other thread, in particular, encapsulate the locks and guarantee that you cannot break proper locking of shared objects by the bug in the using code.
One warning for you: don't rush to say "this is not my problem", first think at my solution thoroughly. You did not specify your problem accurately, to start with. My solution is for a wide range of similar problems. Anyway, your clarifications or follow-up questions are welcome.
—SA