What is the C# equivalent of MsgWaitForMultipleObjects?

后端 未结 2 1114
醉话见心
醉话见心 2021-02-20 13:51

I have a Windows Form with a ListView in Report Mode. For each item in the view, I need to perform a long running operation, the result of which is a number.

The way I

2条回答
  •  逝去的感伤
    2021-02-20 14:17

    The long-running active object, I think, is the best choose in your case. The main thread calls the proxy (of active object). Proxy converts the call method to the message and this message is going to a queue. Proxy returns to the caller the future object (it is a reference to the future result). The dispatcher dequeues messages one by one and realy executes your task in other thread (working thread). When working thread completes a task, it updates the result of the future object or calls callback method (for example, to update your UI).Dispather can have many working threads to execute more the one task at the same time.

    You can see this article (with sample) about long-running active object pattern.

提交回复
热议问题