I found solution, but i'm not entirely sure how good it is.
First i made WCF method that is used to "Subscribe" to events
Interface declaration
[OperationContract]
[WebInvoke(Method = "GET",
BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "Notification")]
Stream Notification();
Service class implementation
public Stream Notification()
{
string result= "";
using (FbConnection conn= new FbConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString))
{
conn.Open();
FbRemoteEvent events= new FbRemoteEvent(conn, "event1", "event2", "event3", "event4");
events.QueueEvents();
AutoResetEvent waitHandle = new AutoResetEvent(false);
eventi.RemoteEventCounts += (sender, args) =>
{
if (args.Counts > 0)
{
result= args.Name;
waitHandle.Set();
}
};
waitHandle.WaitOne();
}
return new MemoryStream(Encoding.UTF8.GetBytes(result));
}
I'm using AutoResetEvent to freeze service instance until post_event happens and once it does happen AutoResetEvent's Set() method is called to unfreeze service and return in my case events name, so i know which event triggered.
On client side i'm calling this method in seperate thread and waiting for its response, once i get it i process it accordingly and resend same method request again so i can catch next post_event.
P.S. You should set your InstanceContextMode to PerCall for this to work.