Web Forms :: Implement MultiThreading In Web Applications?
May 7, 2015i want know how i can insert data to database in background process
like when you like or unlike a post in facebook
i want know how i can insert data to database in background process
like when you like or unlike a post in facebook
i want to impliment multithreading into my web application how to do that..
i have already knew the concept of multithreading but want to impliment into application..
i have developped an application this application runs correctly for 400 users but when more user hits the server than the application fails to respond...
how improve the performance of the application..is this problem is related to the database server of the application server.
How to implement search features in ASP.NET MVC applications
I have a program designed using Asp.net MVC and c#
I want a simple way to implement a search for the data that I have using the models and Controllers
I did it by doing a script in a page itself but I want it by using Models for example I have a table with ( Mean, STD, Parameter , etc )
I want to put these in a dropdownlist and there is a text box to write the value also, there is a flexibility in adding more than one dropdownlist <<< not important
i have a large excel file which has 1 lakh row , i want to insert these data in my table i am using entity framework for insert but it takes more than 45 minutes to insert which is too much, i want to speed up the uploading process what should i do. can I use multithreading for it if yes then how i can use? if any other way to do this process.
View 1 RepliesI've been worked with web services so far, and I'm interested in expanding my services to console applications as well so I started digging up with WCF but I'm conserned that I won't be able to use the HttpContext collection that I've been used to do with web services one important thing which is to generate a random value from HttpContext.Current.Request.ServerVariables["ALL_HTTP"] that I need to reckon if it's the same or at least near what machine that is calling my service. How can I overcome this problem?
I need to know what machine is calling to count the number of attempts to login into my system for example. So must do it inside of the svc code otherwise if I let the client inform what ip address or what computer he is using, anyone could forge this argument and surpass by another machine. May be I'm approaching this matter wrongly. And I should count the number of attempts per state session, but how is it done?
i have some test code which i run at every load of a page in my asp.net website
this is the code
Sub TryThreads()
Dim t1 = New Thread(AddressOf TryLock)
t1.Priority = ThreadPriority.Lowest[code]...
the "dotrace" simply add a record to a log table in the db.now the right result would be that i should have the entries in the db in order "entered","exiting","exited"but actually when i look in the db i see first 2 "entered" then 2 "exiting" etc.meaning that the multithreading is working ok, but not the synclock is that correct?the real code will be adding records to the db and might be called from several pages of different sessions, but the same code must not run twice concurrently.
EDIT:in response to Sashas wonderful post i changed my code to a class (it was in a module) and now it looks like this:
Public Class CheckClass
Property LockObject As Object
Get [code]...
if i open multiple pages at once, they still clash some times. but if i'm correct, the issue is now not with the synclock as much as with the httpruntime.cache, because when using a standard property, on one page, the code works 100%. so how can i make sure that 2 threads, even from totally different sessions never run the trylock simultaneously?
I'm working on my project, I want to ask is it possible to create multithreading in the web method at the web server side instead, not the client side.
View 3 RepliesI wrote the following code to return a pdf report. The code is based on a multi-threading sample code. Can you guys provide some feedback about it, I am new to mulit-thread.
public delegate void StreamResultDelegate(Stream streamResults);
public class GenerateReport
{[code].....
Multithreading in dotnet apps?
View 3 RepliesI want to create a thread in a asp.net mvc application. What will happen?
A) Thread will die when request ends and the response is sent.
B) Thread will continue to run and response will be sent when thread terminates.
C) Thread will run without blocking the response and die when it have completed it's task
I'm currently reading a lot about node.js. There is a frequent comparison between servers using a traditional thread per request model (Apache), and servers that use an event loop (Nginx, node, Tornado).
I would like to learn in detail about how a request is processed in ASP.NET - from the point it is received in http.sys all the way up to it being processed in ASP.NET itself. I've found the MSDN documentation on http.sys and IIS a little lacking, but perhaps my google-fu is weak today. So far, the best resource I have found is a post on Thomas Marquardt's Blog.
Could anyone shed more light on the topic, or point me to any other resources?
My application is a asp.net 3.5 running on iis 6 (windows 2003)
This application is serving 1000's of users daily (100-500 users online).
I want to send an email newsletter to customers weekly.
Around 200,000 emails every time.
This is the code im using:
ThreadPool.QueueUserWorkItem(new WaitCallback(AsyncProcessMailerQueue), null);
private static void AsyncProcessMailerQueue(object data)[code]....
When testing this locally (on my dev machine) i see the application is working alot slower.
Is there a better way to write this code? Should i use ThreadPool.QueueUserWorkItem or create a new thread using Thread t = new Thread(new ThreadStart(DoWork)); ? Will it be better to create a totally seperate application for the purpose of sending the newsletters. will that help if ill run this application on the same machine?
i've seen other posts here talking about ThreadPool vs Thread but its seem no one is sure which is better.
I have a page that has 5 sections. Each section takes about 1 second to render.
Page_Load()
{
RenderSection1(); //1 sec
RenderSection2(); //1 sec
RenderSection3(); //1 sec
RenderSection4(); //1 sec
RenderSection5(); //1 sec
}
I would like to speed up the loading of this page. But at the same time make sure that it don't slow down performance of other parts of web application and also do not crash the IIS.
The are several approaches:
Use AJAX requests. Needs to be MVC style requests to Controller or Web Service. Using UpdatePanel around each section will not work - since if I try to submit refreshes to multiple UpdatePanels at the same time using approach here: [URL], the last request will always win: [URL] Use ASP.NET threads described in answer to right way to create thread in ASP.NET web application. So I would use a separate thread for each call: RenderSection1, RenderSection2, etc... Move the logic that takes up time, usually DB requests, into Application Service class in another DLL or External Web Service. Something like
OrderDTO GetDataForViewOrder(int orderID)
{
}
and use multiple threads in that DLL. This approach seems to provide the best scalability, but also introduces UI details into Application Services layer.
I've got an ASP.net page that runs a script which takes anywhere between 1 second and 10 minutes to run dependant on the parameters passed in to it. My question is, if the server is multicore, will this script automatically make use of all the processors, or is it constricted to one.
View 3 RepliesI am writing a program to crawl the websites. The crawl function is a recursive one and may consume more time to complete, So I used Multi Threading to perform the crawl for multiple websites. What exactly I need is, after completion crawling one website it call next one (which should be in Queqe) instead multiple websites crawling at a time.I am using C# and ASP.NET.
View 4 RepliesOur corporate intranet is designed so that each web application is a child application in the primary application.. Everything has worked fine with Visual Studio 2008 and even in 2010 running the website locally works great, the output directory for the child apps is ..in and the ProjectName.dll copies to that directory.. When I do a publish however it does not and I have to manually copy the dll from the bin folder in the project folder to the parent bin folder, this isn't hard of course but more of a pain in the butt each time I need to publish something. I made sure the output directory is correct for both debug and release yet on publish is just copies it to the child bin and not the parent bin as needed.
View 2 RepliesWhen I serve an ASP.NET page, can I render the various controls on the page in parallel?
I have a few Telerik controls (RadGrids) on the page and when I step through the page being loaded, it seems as though the controls are databound and rendered serially.
Maybe this behavior is because I am hooked in with the debugger.
Is there anyway to load the page and have select controls build on separate threads? Is that even conceptually possible or must it be done sequentially?
I am creating a multithreading application and I am using countdownevent to signal my object arround 3 times and using wait , but somehow the session goes null , although I am setting a breakpoint after mycountdownevent.wait() and the breakpoint isnt reached , that means the execution is not done...so can someone tell me what is wrong?? here is my code :
this is the main thread
[Code]....
this is the upload image method :
[Code]....
and this is a property for the countdown event :
public
CountdownEvent
_3adasehCountDownEvent;
In an ASP.NET application, I have a resource that is protected by a ReaderWriterLockSlim.
Normal requests call EnterReadLock, access the resource, call ExitReadLock and return.
At one moment, I accidently forgot to put a call to ExitReadLock somewhere in my code. On the next request, I got an exception stating that the thread had already entered the lock.
Fair enough: if at the end of request A the thread does not exit the lock, and that same thread is used to process request B, and tries to enter the lock, it will throw.
Now, my question: is the following scenario possible? reasons?
thread begins to process request A
thread enters lock
thread does, say, sleep, or do some IO, and so becomes available same thread begins to process request B, while request A is "on hold"
thread enters lock !! throws !!
If yes, what other solution do I have to protect said resource? Bearing in mind I want to use a ReaderWriterLockSlim because I also have other thread that may write to the resource?
edit: add some details: 1) This happens in the ProcessRequest method of an HttpHandler which generates, caches and serves images. These images are expensive to generate. So, the first request will generate and cache the image, and we want to put the other requests on hold while generating.
2) We have not tried to "reproduce" -- at the moment we're trying to know if it is possible or not that the same thread begins processing a request while already waiting for the image to become ready.
3) I am aware of the LockPolicyRecursion but I am not sure I fully understand its purpose, and whether it would be OK to set it to SupportsRecursion in our case.
edit: going further...According to the document pointed to by Ryan below, a thread will block and not return to the pool as long as we don't engage into async operations. So once we've locked the thread waiting for EnterReadLock to complete, it won't return to the pool nor process any other request.
So 1) we should be safe but 2) we might starve the thread pool. Assuming we don't want to immediately return a dummy "please wait" image, what solutions do we have?
how can data be transfered between 2 web applications runnig on 2 web servers
View 4 RepliesI would like to implement the following functionality between 2 web applications:
a) Web application one contains a button, which, when pressed launches another web application.
b) The second application contains a form that is filled in by the customer.
c) After filling in the form, the second application validates the information and returns a 5 digit code to indicate whether validation was successful.
d) Web application one then displays the status and asks the user to continue with other steps.
Is the above scenario possible? Is it possible to transfer data between 2 seperate web applications? I have considered using a query string, database and flat file to trasnfer the data from one application to another. Which of these (if any) would be the best choice?
I'm reading about URL routing at How to: Define Routes for Web Forms Applications and there's something in the example I don't understand. If you look at the example provided below,
routes.MapPageRoute("", "SalesReport/{locale}/{year}/{*queryvalues}", "~/sales.aspx");
im about to wirte an app that is an extension from the main application that is hosted on the IIS. My application is going to work as a child app (main app as parent) working in main application pool. User will be redirected from the menu to main app to my website. And here is my problem. I would like to pass informations like user login, login state etc. I cant do it via Query String - that wouldnt be safe. I thought I could pass it via Session state, since the SessionID is the same both sides but I cannot retrives parameters on my website(theyre null).
View 2 RepliesI have several applications in different domains with the same code, how feasible that through the admin domain [URL] read the file. aspx.
If I upgrade an application, I copied every current updates on all domains.
I could use to copy the file only once on the server [URL] and in all domains, the update fixes.
I'm using a common <machineKey> to allow two ASP.Net applications to share a single forms authentication ticket (ie. only need to login to one application to access both). My problem is that I only want users in a particular role to have access to the second application. What's the best way to implement this?
I've tried checking the role in Application_AuthenticateRequest() and doing FormsAuthentication.SignOut() if the role doesn't match, but that doesn't get picked up until the second request to the application. I can't redirect from Application_AuthenticateRequest() because that would just create a redirect loop.