asynccallback

asp.net AJAX best practise for client calling slow async process on server

和自甴很熟 提交于 2019-12-22 08:40:33
问题 I have a service that performs a slow task, when its finished I want to update the client using AJAX with the result of the task. In my client I call the task many times to update a grid of results. For the purposes of understanding, its a connection tester that loops through a list of connections to see if they are alive. I have implemented the service as WCF. I generate async methods when I add the service reference to my web client. The code works fine, however the screen locks momentarily

JavaScript doesn't seem to wait for return values

半腔热情 提交于 2019-12-18 12:08:23
问题 I've been struggling with this for a while now. I'm new to Javascript, and have been under the impression that the code I've been writing has been running asynchronously. Here is a generic example: I run some code in function a. Function A then calls Function B, who needs to return a variable to A so A can use it in its later operations. It seems though that when A calls B, it still continues to run its own code, not waiting blocked for its return value, and B isn't fast enough such that A

Powershell: AsyncCallback Events using Hidlibrary

女生的网名这么多〃 提交于 2019-12-13 05:00:08
问题 I need some help implementing asynchronous events in Powershell. As a testbed for a larger HID project I want to use Powershell to read the data from a usb panic button that I got off amazon. The perfect solution would implement the data callback as an event that could then be registered using Register-ObjectEvent. My current approach is to use the Hidlibrary library. I am having difficulty invoking both the Read() or ReadReport() methods. They do not appear to be typical asynccallbacks and

How do I share an AsyncCallback with many APM BeginXXX calls?

折月煮酒 提交于 2019-12-12 14:53:36
问题 I want to re-use my code with many APM-style async methods. Each method has a BeginXXX and an EndXXX signature pair. I want to reuse the same callback in each of the functions. I have always used anonymous methods like the one below, but I'm not sure how to extract it into a reusable form. I know this should be easy, but I can't figure out how to use a delegate to make this happen. (this is what I get for being self taught) var result = tableSymmetricKeys.BeginExecuteQuerySegmented(query,

How to write your own Get / Request function with serial port data?

…衆ロ難τιáo~ 提交于 2019-12-11 15:55:17
问题 I have a class that talks to a serial port and I want to mimic a Get function. The problem is, the serial port feeds in raw data which may or may not come. It also has to be processed and parsed. For example, if I want to get a Person object, the serial port class does this. A method to send the request for a Person. Something happens on the serial device... it might respond, it might not. Bytes come in through an event handler that processes and parses all data, and eventually a Person

How do you stop a function when an Error object is received?

*爱你&永不变心* 提交于 2019-12-11 13:18:27
问题 How do I stop the function at the point an error occurred. I am making an http post call. I have constructed an error-first style callback function. How do I stop the callback function if an Error object was passed in it? In my use case, I need to stop regardless of error type as I need the data object for subsequent chain of callback functions. Is it simply return ? I have read what return does on a higher level so hoping to get confirmation if my code is right for what I would like to

Wrapping Auth0's parseHash function in a Promise

南笙酒味 提交于 2019-12-10 21:37:03
问题 auth0.js has a function that's used to parse the URL hash fragment and extract the authentication result therefrom. I'm wrapping this function within one called loadSession as follows: public loadSession(): void { this.auth0.parseHash((err, authResult) => { if (authResult) { window.location.hash = ''; localStorage.setItem('token', authResult.accessToken); // TODO (1) } else if (err) { // TODO (2) } }); } As seen above, parseHash takes a callback function as an argument and I cannot control

C# Socket.Receive message length

坚强是说给别人听的谎言 提交于 2019-12-09 05:52:59
问题 I'm currently in the process of developing a C# Socket server that can accept multiple connections from multiple client computers. The objective of the server is to allow clients to "subscribe" and "un-subscribe" from server events. So far I've taken a jolly good look over here: http://msdn.microsoft.com/en-us/library/5w7b7x5f(v=VS.100).aspx and http://msdn.microsoft.com/en-us/library/fx6588te.aspx for ideas. All the messages I send are encrypted, so I take the string message that I wish to

Javascript function returning undefined value in nodejs

痞子三分冷 提交于 2019-12-09 04:44:38
问题 I am writing code for getting data. First I call **getsomedata** function to get data and inside getsomedata function I am calling another function getRandomdata to get data and returning it back to the previous function but it is returning undefined . But in getRandomdata data could be seen in console.log . Do I need to use callbacks ? router.get('/get-data', function (req, res, next) { var result = getsomedata(some_parameter); console.log(result); // receiving undefined res.send(result); })

Async TCP Server for multiple Clients

自作多情 提交于 2019-12-07 09:59:32
问题 I've got an TCP Server that listens asynchronously for incoming connections. Everything works fine if just one client is connected. But if there are two or more connections, the Server doesn't get the first message. When i debug the ReceiveCallback function i can see that the Server gets the length of the message but not the data. I.e. if I connect two clients and try to send the first message: "hello", the server gets: received = 5; buffer= /0/0/0/0/0, so nothing is displayed. In the second