Solved

session-based multithreading in asp.net 4.5

Posted on 2013-11-06
6
354 Views
Last Modified: 2013-11-12
I am using vs2012 and .net 4.5.  I would like to know how to implement session-based background worker thread in web application using c# code-behind.  any help appreciated.
0
Comment
Question by:dhenderson12
6 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 39629989
Here is some code that shows a possibility:

Background worker thread in ASP.NET (CSASPNETBackgroundWorker)
http://code.msdn.microsoft.com/CSASPNETBackgroundWorker-5a0cea51
0
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 39629996
To do what?
Is it by session or by user?
0
 

Author Comment

by:dhenderson12
ID: 39630379
TheLearnedOne:  I have looked at this code, but have a question about it ... does the background thread that's stored in the session end when the session times out?  What is the lifetime of the background worker?

AlexCode:  I have a continuous polling situation to a web service.  I need to run it in it's own thread because it causes all the code behind to stop if I just make the method async and run it in an update panel based on a timer.  don't really know why that behavior is happening ...
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 39630482
You're using a long-polling technique to call a method that takes a lot of time to process?
It doesn't seem like a good thing even in a separate thread...

This won't solve your heavy process problem but might improve your real-time notification system: http://signalr.net/
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39632017
There is a note on the Default.aspx page:

Try to open this page in two browsers which use different sessions and then run the operation at the same time.  You will learn that each session has its own Background Worker. It is not shared by all users.

When the session ends, the background worker ends.
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 39632042
@AlexCode you read my mind, but @dhenderson12 tred with caution if this is not internal...

@dhenderson12 you need to sort out the async issue, if this is read only output then run a separate service that throws it into a cache - don't bog down the web server that needs to be fast. Try and separate your concerns - how are you unit testing this anyway?
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now