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 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.
Related
I'm using Microsoft's C# API for the Cognitive Services (Project Oxford) Bing Speech Recognition service. Specifically, I am using Microsoft.ProjectOxford.SpeechRecognition-x64 version 0.4.10.2.
I send audio to the DataRecognitionClient using the SendAudio and EndAudio methods, and wait for the final set of recognition hypotheses via the OnResponseReceived event. The issue I'm running into is that it's easily possible to have more than one oustanding recognition request, and the SpeechResponseEventArgs object passed to the OnResponseReceived handler doesn't contain any information telling me which request it is a response for.
Here's an example that has actually happened to me many times:
Person says something, call it utterance A, and I send it via SendAudio and then call EndAudio when they are done talking.
While still waiting to get the OnResponseReceived event for utterance A, the person says something else, call it utterance B. Again I send it via SendAudio and then call EndAudio when they're done talking. I still haven't gotten an OnResponseReceived event.
I finally get my first OnResponseReceived event.
I get a second OnResponseReceived event.
How can I correctly associate the responses with the utterances?
Is there an ordering guarantee such that if I send utterance A and then B, I will always get the response for utterance A first? I haven't seen that guarantee in the documentation.
Since all the requests are asyc requests there is no guarantee that A will always come after B. The best approach I would recommend is to create a pool of recognitionclients and use one for every recognition and manage the dependency,
I have been looking at TAPI, I can detect calls, make calls, answer/reject calls... however the only reason im even looking at it is to get the CallerID.
I know the hardware I am using works for CallerID as I have used other software to check before hand.
I have tired using the COM obeject directly, using JulMar's wrapper, and using TAPI 2.0 and I am yet to find a way that works.
From my understanding the callerID should come through via TE_CALLINFOCHANGE.
The problem is the event never fires, and the callerID is always blank on the other events.
Has anyone had success with this?
Thanks
May be the TSP doesn't send the message about a call info change, and the information never changes because it is present from the start of the lifetime of the call.
The call info is always present for a call and you can ask for it at any time. Just retreive it from the call, with ITCallInfo::get_CallInfoLong (lineGetCallInfo).
For a call tracking application I'm developing, I want to maintain local database.
As it stands, the application searches for new records in Twilio and inserts them into my database every time it loads. This is very time consuming.
In order to avoid that runtime expense, is there a way I can use usage triggers in Twilio to automatically populate my database in real time? Or even just daily?
If not, how can I achieve something like this?
Since Twilio is already calling your servers (unless there's some way to use it without doing that, but I don't think there is), can't you implement logging there? For instance, before you feed back your greeting, pop in a logging routine to note that you've received a call?
I'm not sure if they offer any other sorts of APIs or callbacks, but I really don't see why anything like that would be necessary. It'd just tie up your servers with more requests at no additional gain. I was just going through their documentation and I don't see anything like this. I could be just totally glossing over it, but again it just seems redundant. The entire Twilio system is based effectively on event hooks, so having separate ones wouldn't serve much additional use.
On the other hand, if for some reason you have absolutely no access whatsoever to the code or people behind the code that serves TwiML back, unless someone else is seeing an event hook API, you might want to just set up a scheduled job on your server (or in Azure, or whatever you're using) to query Twilio daily, since I know you mentioned that that would be sufficient. You could also, of course, set it more frequently. But that really seems like a waste of resources and effort when they're already telling you everything about every call through the massive list of query parameters they pass with every request.
I'm doing some work with a radio microcontroller (BLE). The mechanism supported in .NET's GenericAttributeProfile namespace, is to use an EventHandler whenever new data comes in (notifications). A problem I'm currently seeing is that, despite my data being sent in order from the radio hardware, the data does not necessarily get dealt with in that order. I'm guessing this is due to the asynchronous manner in which the EventHandler is invoked (please correct me if I'm wrong). Every time a new piece of data comes in, the event handler is invoked, which then reads the data, and writes to console the data and a static variable which increments every time the event handler is called (not thread safe, but seems to be OK for testing). The data it is printing out if also incrementing, and I can see that the events are being handled out of order.
So my question is, how do I ensure that events are handled in order. From the research I've done, I can only find literature on the order of eventHandler execution. I don't care about that here as I only have 1 eventHandler. I care about the order of event execution
UPDATE 09/15/2014
I just wanted to let everyone know that I actually had 2 issue going on. I had originally thought that it had to do with thread timing but that was only part of the problem (for me anyway). After I fixed my thread timing issue I found out, as the original poster had stated, the events are in fact coming in out of order. I have confirmed this issue with Microsoft and they are now working on a fix. As soon as I get a resolution from them I will post it here.
UPDATE 01/08/2015
Microsoft has finally reached out to me and has confirmed the issue. However, they determined that the cost to benefit was too high to add to the 8.1 core so they won't introduce a fix until the next major release of windows.
I'm looking for a way to retrieve a collection of DTOs from my WCF data service in a way that will allow me to be informed every time a whole DTO from the collection has finished downloading, also I want to be able to read it of course.
Means, if I want to get a collection of users, every time a user from the collection is downloaded completely to the client (serializably-speaking), I want the client-side to be notified and be able to read it.
Is it at all possible?
Thanks!
Edit:
Is passing a callback from the client to the server, which the server will use to send the client each user through iteration, a possible/correct direction? Or is there a better solution?
You’ll probably have to split it into multiple requests in order to do this. For example, one request to retrieve the size of the collection, and then a separate request for each item in the collection. Then you know when each item completes. (If you do this, you can even parallelise the whole thing.)
You can't really subdivide a single call easily, so you'd best making one or two concurrent calls, and getting the objects individually. Using some kind of manager class, and some multithreading, you could have an event fired when a call was completed - and map that to an 'object downloaded' event.
Hope that helps.