में उपयोग करने वाले विधियों के लिए कैसे पास करें, मेरे पास दो विधियां हैं जो उपयोगकर्ता आईडी प्राप्त करने के लिए HttpContext.Current का उपयोग करती हैं। जब मैं इन पद्धतियों को अलग-अलग कॉल करता हूं, तो मुझे उपयोगकर्ता आईडी मिलती है लेकिन जब उसी विधि को समानांतर का उपयोग कहा जाता है। इन्वोक() HttpContext.Current शून्य है।HttpContext.Current को parallel.Invoke() में .net
मैं कारण पता है, मैं सिर्फ मैं HttpContext.Current लिए पहुंच सकते हैं का उपयोग कर के आसपास काम करने के लिए देख रहा हूँ। मैं इस सुरक्षित थ्रेड नहीं है पता है, लेकिन मैं केवल पढ़ने कार्रवाई करने के लिए चाहते हैं
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Display();
Display2();
Parallel.Invoke(Display, Display2);
}
public void Display()
{
if (HttpContext.Current != null)
{
Response.Write("Method 1" + HttpContext.Current.User.Identity.Name);
}
else
{
Response.Write("Method 1 Unknown");
}
}
public void Display2()
{
if (HttpContext.Current != null)
{
Response.Write("Method 2" + HttpContext.Current.User.Identity.Name);
}
else
{
Response.Write("Method 2 Unknown");
}
}
}
धन्यवाद