为了账号安全,请及时绑定邮箱和手机立即绑定

C# 网页中的异步是不是只能用ajax来请求啊?我用BeginInvoke这种异步请求会出错..

C# 网页中的异步是不是只能用ajax来请求啊?我用BeginInvoke这种异步请求会出错..

BIG阳 2018-12-07 09:48:53
我用异步请求的代码如下,运行的时候会出错,怎么写才正确呢? using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Threading; using System.Runtime; namespace WebApplication2 { public partial class WebForm2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Test t = new Test(T); t.BeginInvoke(new AsyncCallback((Ir) => {Response.Write("eeeeeeee"); }), null); Response.Write("dddddddd"); } private void T() { Thread.Sleep(10000); } delegate void Test(); } }   另外,在web编程中多线程是不是基本都用不上?都是用ajax来请求的呢? 谢谢指导!
查看完整描述

2 回答

?
蝴蝶刀刀

TA贡献1801条经验 获得超8个赞

你写的那个是在服务器端的异步操作,我们一边说的异步,都是指的客户端通过ajax,异步的去取得服务器端的数据,也就是指的,页面不刷新

查看完整回答
反对 回复 2019-01-21
  • 2 回答
  • 0 关注
  • 315 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信