简体   繁体   中英

How to populate Gridview using Web Forms in asp.net asynchronously?

I have code from windows forms that discovers all devices on the specific network asynchronously. When this happens I have used listview1.invoke(shown below) with my delegate to execute on the specified thread.The AddDiscoveryEntry method then updates the listview. However asp.net does not contain a definition for invoke. How can I populate gridview asynchronously with the devices that are discovered when they are discovered in asp.net?

listView1.Invoke(new AddTolstDiscoveredDevices(AddDiscoveryEntry), ReceiveString);

Remember that the web is stateless. When you make a request, the server processes it, constructs a response, and sends it back to the browser, at which point the browser considers it complete. Each request/response is self-contained, and once that response has been sent, without something like SignalR (which SLaks suggested), there is no mechanism to continue to send additional data/updates down to the client. That leaves you with the option of either polling for changes (using AJAX or page refreshes, which aren't always ideal), or implementing technology that allows for more bi-directional communication. A gridview won't do it for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM