Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create single async webmethod on asp.net webforms to long polling

I am working on a little project that I want to implement long polling in. I do not want to use SignalR or any other third-party libraries for this. I have a ASP.NET WebForm that I implement a simple web method, exposed through the asp.net page (decorated with the [WebMethod] attribute).

This is a very simple project and only this single method needs to be used in an async fashion so it isn't using threads from the request pool. I'm not interested in third-party libraries that accomplish this, MVC Async Controllers, entire Async Webform page, etc... I am just looking for a simple implementation to get this to work on a single method that will be requested via AJAX requests from the client.

So far I'm not sure how to approach it as most of the resources I have found out-right implement async for the entire project, which is NOT what I want.

Anyone have any ideas or resources on how I can accomplish this small thing?

like image 895
Justin Avatar asked Apr 03 '13 18:04

Justin


1 Answers

There is an MSDN Sample that uses the ManualResetEvent class, a script manager control, and a webservice to implement long polling (they call it reverse ajax in the sample).

http://code.msdn.microsoft.com/CSASPNETReverseAJAX-7a1f0c2b

like image 115
Steve Clanton Avatar answered Oct 31 '22 08:10

Steve Clanton