C# Communication between threads

后端 未结 6 490
情话喂你
情话喂你 2021-01-11 22:34

I am using .NET 3.5 and am trying to wrap my head around a problem (not being a supreme threading expert bear with me).

I have a windows service which has a very int

6条回答
  •  逝去的感伤
    2021-01-11 23:29

    You can use the Singleton pattern. In your case, make the connection a static object. Both threads can access the object, which means construct it and use it.

    The main thread could construct it whenever required, and the worker thread access it whenever it is available.

提交回复
热议问题