Solved

session-based multithreading in asp.net 4.5

Posted on 2013-11-06
6
370 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
Technology Partners: 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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

729 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