开发者

3rd party dll raising events

I use a third party dll to get some data from their servers. There is a void method that I call and then i subscribe to an event raised by the call to this method. The event raised returns the开发者_如何学JAVA data through its parameters.

so, call to : void getdata(id) raises: void onReturn(object) --> which returns an object that has the data.

This WORKS everytime when there is a single call to getdata(id)

The problem is when i loop through the list of ids, and inside that loop call getdata(id) for that list, the corresponding events are not raised properly. Say for a list of 10 ids, there are 10 calls to getdata(id) but only few onReturns are raised.

The returned object also returns the id that was passed to getdata(id) so I can match the data i sent and the data that i receive.

Is there a way to make sure that all events get listened to? So if I send 10 ids by getdata(id), I want to make sure that the 10 onReturns are processed.

And i'm using c#, .net 4.0

Thanks


If it's a third party DLL, there's no telling how they've implemented it. When you step through in Debug mode, do you get past the call to getData() before the onReturn() listener is called? If so, it might be using threads (or at least asynchronous listeners) internally, and calling multiple getData()s too close together might cause it to stomp on pending responses.

The only way I could think to try and get around this is to use multithreading yourself, e.g. with a Mutex that waits after the call to getData() and releases in the onReturn() event. This way you'd only have one outstanding request at a time, which seems to be the condition that works for you.

Edit: Have you talked to the third party vendor about this yet? I'm guessing their support isn't the best if you thought of us first, but it might be worth a shot.

Edit the second: When you say it gets data from their servers, does this mean it makes requests over the network? If those requests aren't encrypted, perhaps you could reverse engineer the protocol and make a new API for yourself instead of relying on a proven buggy black box.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜