异步线程和会话 [英] Asynchronous threads and session

查看:89
本文介绍了异步线程和会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在新的异步线程一直使用这个签名催生,将在ASP.NET会话对象提供给这个新线程?

  IAsyncResult的asyncCall = f.BeginInvoke(NULL,F);


解决方案

我不知道哪些会话对象你在谈论,但如果你谈论的ASP.NET会话可能无法使用。此外,它是不好的做法,从后台线程访问ASP.NET会话。我建议你​​传递一个包含所有必要的信息,以这样的背景下胎面的对象,而不是让它拉东西从会话=>使得它不太可重复使用的。

通常情况下,如果此线程的调用者等待其完成会话应提供所有沿但老实说它是坏的设计,我会简单地避开它。

When a new async thread has been spawned using this signature, will the ASP.NET session object be available to the this new thread?

IAsyncResult asyncCall = f.BeginInvoke(null, f);

解决方案

I don't know about which session object you are talking about but if you talk about the ASP.NET Session it might not be available. Also it is bad practice to access the ASP.NET Session from background threads. I would recommend you passing an object containing all the necessary information to this background tread instead of having it pull stuff from a session => makes it less reusable.

Normally if the caller of this thread waits for it to complete the session should be available all along but honestly it's bad design and I would simply avoid it.

这篇关于异步线程和会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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