Solved

session-based multithreading in asp.net 4.5

Posted on 2013-11-06
6
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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