Wait inside method until event is captured

后端 未结 3 1829
心在旅途
心在旅途 2021-01-02 02:45

I have this issue with a method in C#. I made a method that calls a function from a dll its called Phone.GetLampMode(); Now Phone.GetLampMode doesn

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-02 03:21

    It looks like the existing model is close to the Event-based Asynchronous Pattern (EAP). You might want to look at the article Interop with Other Asynchronous Patterns and Types which describes how to convert such a pattern to the newer Task-based Async Pattern (TAP).

    Once you have a Task (or Task, you can just Wait for it.

提交回复
热议问题