Solved

session-based multithreading in asp.net 4.5

Posted on 2013-11-06
6
356 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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