异步线程和会话

编程入门 行业动态 更新时间:2024-10-26 22:28:11
本文介绍了异步线程和会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在新的异步线程一直使用这个签名催生,将在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.

更多推荐

异步线程和会话

本文发布于:2023-07-13 03:11:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1099759.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!