Vb.net async webrequest [英] Vb.net async webrequest

查看:54
本文介绍了Vb.net async webrequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿!



我想知道是否有人可以帮助我:



我有调用函数的ajax请求

在该函数中我创建了一个对酒店API的Web请求

响应包含30个结果



我想将结果返回给View并启动immediatley另一个ajax请求,该请求使用web worker调用一个函数,该函数获取其余的500个结果并将其保存在数据库中



这个函数应该只是调用但是还没有等待完成



我希望我解释它不要太困惑:)



非常感谢提前



干杯

解决方案
嘿!感谢您的回复!我已经解决了问题:)

我创建了一个返回JSON的函数,但在它返回之前它调用了一个子程序:



 函数 testFunction()作为 JsonResult 
System.Threading.ThreadPool。 QueueUserWorkItem( AddressOf DoAsyncWork)

返回 Json( success,JsonRequestBehavior.AllowGet)
结束 < span class =code-keyword>功能

受保护的 Sub DoAsyncWork()
执行部分工作
结束 Sub





无论如何,谢谢你的帮助

干杯!


Hey!

I was wondering if someone can help me with that:

I have a ajax request that calls a function
in that function I create a web request to a hotel API
the response contains 30 results

I would like to return the results to the View and start immediatley another ajax request that calls a function with a web worker which gets the rest of the eg 500 results and save them in a database

this function should be just called but not been waited to be finished

I hope I explained it not too confused:)

thanks a lot in advance

Cheers

解决方案

Hey! Thanks for your reply! I have solved the problem :)
I created a function with return JSON but before it returns it it calls a subroutine:

Function testFunction() As JsonResult
   System.Threading.ThreadPool.QueueUserWorkItem(AddressOf DoAsyncWork)
 
   Return Json("success", JsonRequestBehavior.AllowGet)
End Function
 
Protected Sub DoAsyncWork()
   Do some work
End Sub



Anyway, thanks for your help
Cheers!


这篇关于Vb.net async webrequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆