开发者

EvtSubscribe Pull Vs Push Model

I am trying to use following api from windows.

EVT_HANDLE WINAPI EvtSubscribe(
  __in  EVT_HANDLE Session,
  __in  HANDLE SignalEvent,
  __in  LPCWSTR ChannelPath,
  __in  LPCWSTR Query,
  __in  EVT_HANDLE Bookmark,
  __in  PVOID context,
  __in  EVT_SUBSCRIBE_CALLBACK Callback,
  __in  DWORD Flags
);

This api supports two models for subscription PULL and PUSH

There are two subscription models: the pull model and the push model. In the push model, you implement a subscription callback and set the Callback parameter to your implementation. The service will call your callback for each event that matches your query criteria (or if an error occurs).

In the pull model, you create an event o开发者_开发知识库bject that the service signals. When signaled, you call the EvtNext function using the subscription handle to enumerate the events. You must call the EvtClose function on each event that you enumerate. You then reset the object and wait for the service to signal again. This process repeats until you cancel the subscription.

I want to know which model will be scalable. and what are the pros/cons of choosing one model over another.


Callback function is called from another thread, so you may have to synchronize, and if you have to synchronize it will be easier with the pull model... And if synchronize it will be easier to close the subscription with Event, as you may wait on two event, the one from EvtSubscribe and the one to close... I waste some hours understanding why my call to EvtClose hangs with the callback model !


Agree with Jean Davy

Pull method will help you in handling multithreading more easily as essentially the main thread will be able to handle everything. its simpler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜