How To Optimize The Performance Of A Thread Running In Background

Feb 4, 2011

In my website, I am using thread to perform a repetitive process in background. Now the process takes around 30 to 45 seconds to update the database.

Basically the function performs the following:

1) Download the CSV from a website.

2) Parse the CSV and update the database tables.

I want to optimize the performance and decrease the time it takes to 15 seconds.

How can I do this?

EDIT:

Here is the Code:

[code]....

View 1 Replies


Similar Messages:

Does The Continuously Running Thread In Background Impact The Website's Performance

Feb 3, 2011

In my website I am using thread to perform the function which downloads the CSV from a website and parses the data into the database.

Now if I am not able to stop the thread then what could be the impact on the performance?

Also If I unknowingly start another thread then would it impact my website's performance?

View 3 Replies

Getting Website's URL Without HttpContext.Current (running In Background Thread)?

Aug 3, 2010

Bit of a long shot, but is there a way in ASP.NET to dynamically get the website's URL [URL] when there is no HttpContext.Current available.

There is no HttpContext because the code is running in a background thread* (but under the ASP.NET AppDomain). I have a background process that sends emails out every evening, and needs to include the Web address, but I don't want to hard code it because of deployments and testing (it changes from [URL] to[URL] and then to [URL] for the live site).

View 2 Replies

DataSource Controls :: Running SQL Query From SQL Management Studio - Optimize?

Jun 29, 2010

I have one query which is not responding even after 4 minutes. But same query is when called from asp.net pages (though stored procedure), responds within 10 seconds. My Query:

[Code]....

I don't want to know the ways to optimize the query as I have already changed the query and now it responds within fraction of second. I just want to know that, why it was not reponding after 4 minutes in SQL Management Studio and responds in just 10 seconds when run from asp.net through stored procedure. I am using SQL 2008 Express with Advanced services and .NET 3.5.

View 4 Replies

C# - Set Thread As Background Or Not

Jan 2, 2011

I need an explanation regarding some advice I got on this site. I'm doing a newsletter sending app, and I have my mail sent in a seperate thread so the process doesn't slow down the whole web site. A couple of people advised me to set the threads IsBackground property to true. I did this, but was also courious about what this does, so I googled a bit.

As it turns out, setting the IsBackground property to true indicates that "it's okay if the process shuts down while this thread is still running.". Or as microsoft puts it "Any remaining background threads are stopped and do not complete." I don't know if I got this the wrong way but, wouldn't it be better to leave the IsBackground property to false, so that the spawned thread can complete its work regarding the main thread?

View 2 Replies

C# - Creating A Background Thread In A WCF Service During A Call?

May 21, 2010

The following code is part of a WCF service. Will eventWatcher take up a thread in the ASP .NET thread pool, even if it is set IsBackground = true?

[code].....

View 1 Replies

C# - Finding Information About Sending Emails In A Background Thread?

Jan 21, 2010

I have a thread running in the background that will sleep and pull data from the database when something wakes it up. I am sending the emails using google apps using SmtpClient (code below).

I wanted to know if there is anything i be aware of? I plan to send only one email at a time (a registration or forgot password email). I am a little worried something can happen like an invalid email locking up the thread because i didnt set a timeout or maybe google apps happen to be done and causing the app to blow up. What should i be aware off? I should ask how i should test as well?

[code]....

View 4 Replies

Asynchronous HTTP Handler And Using HttpContext In A Background Thread?

Feb 10, 2010

I was reading Walkthrough: Creating an Asynchronous HTTP Handler and noticed they pass the HttpContext from the handler thread and use it in a WaitCallback which runs on a background thread. It makes calls like _context.Response.Write(). Am I correct in assuming that this doesn't violate the fact that HttpContext is not thread safe because the handler thread will not be using it after the async work has started?

Also, Using an HTTPContext across threads has some good information about HttpContext and threads. Is all of HttpContext not thread safe, or just items like Response? Can multiple background threads access the Items property, if only in read mode?

View 1 Replies

C# - Continuously Running Thread In Web Application?

Mar 31, 2011

i want a continously running thread in my web application for sending mail to admin if the logged complaint of the user in not solved by technician within 24 hours.

i am able to send mail to administrator

i just want a watch on database for unsolved issues with timespan of more than 24 hours and inform to administrator about the same

View 3 Replies

C# - Can Execute A Stored Procedure Using Linq In A Background/alternate Thread

Feb 4, 2011

In my app I am using the open xml sdk to generate a word document and write the file to the response.output stream for the user to download.

At the time that the letter is generated I also need to call a SP via linq data context to update a row in my db.

I think that I need to execute this SP in a seperate thread so that I can simultaneouly write the file to the output. my method looks like this...

protected void btnPrint_Click(object sender, EventArge e)
{
//call sp to update
//create letter and send to client
}

Is this feasible or should I avoid seperate threads?

View 1 Replies

ThreadPool Thread Running As User =ASPNET

Nov 24, 2010

I have a web service that uses ThreadPool to delegate a task to a thread but it runs on ASPNET (System.Environment.UserName) while the main thread runs as windows account. How can I make this thread run with same windows account. Note that I have impersonate=true in web.config. This is causing problems accessing database.

View 1 Replies

Configuration :: Unable To Pass Session With Modal Popup Extender And Background Thread

Oct 2, 2010

I have a problem with a Model Popup Extender that monitoring a background thread.

I need to give feedback to the user about tasks that happend in the server side.

So searching on internet this give me a solution [URL]

Launch a thread, passing the Session variable, update a flag and a mesage and show the info in the web with a timer.

almost all, is fine, in one server (sadly, close to production) after the task (and thread) is completed, the Session variable is set to null and the user is redirected to a "Session Expired" Page.

[code].....

I noticed that this is a very slow server and some websites are very slow.

Session is managed with cookies and the timeout is set to 30 min.

View 1 Replies

How To Start A New Thread To Query A Database While Web Application Continues Running

Feb 11, 2011

I want to start a new thread to query a database while my web application continues running. I was under the impression that by using threads I can run the querying process independently while the normal web application page cycle carries on, but I could be wrong.

public class DbAsyncQuery
{
Dictionary<string, object> serviceResults = new Dictionary<string, object>();
public void UpdateBillingDB()
{
QueryAllServices();
foreach (KeyValuePair<string, object> p in serviceResults)
{
IEnumerable results = (IEnumerable)p.Value;
IEnumerable<object> sessions = results.Cast<object>();
DbUtil.MakeBillingDBEntry(sessions, p.Key);
}
}
public static string[] servicesToQuery = new string[] // Must go in config file ultimately
{
"xxx.x.xxx.xx"
};
public delegate void Worker();
private Thread worker;
public void InitializeThread(Worker wrk)
{
worker = new Thread(new ThreadStart(wrk));
worker.Start();
}
public void InitializeQuery()
{
Worker worker = QueryAllServices;
InitializeThread(worker);
}
private void QueryAllServices()
{
Dictionary<string, DateTime> lastEntries = DbUtil.GetLastEntries();
foreach (string ip in servicesToQuery)
{
string fullServicePath =
"http://" + ip + ":800/MyWebService.asmx";
//object[] lastEntry = new object[] { lastEntries[ip] };
object[] lastEntry = new object[] { new DateTime(2011, 1, 1, 0, 0, 0) };
object obj = WebServiceHandler.CallWebService
(fullServicePath, "MyWebService", "GetBillingDBEntries", lastEntry);
serviceResults.Add(ip, obj);
}
}
}

It seems to basically stall and wait to finish the query before loading the page (which can be thousands of rows, so it takes awhile). I put this in the following section of Global.asax:

protected void Application_Start(object sender, EventArgs e)
{
DbAsyncQuery query = new DbAsyncQuery();
query.UpdateBillingDB();
}

This is one of my first web pages, and I'm new to threading. I understand there is a difference between creating your own thread and using the ThreadPool. In this method, I am using my own thread, I think. Not sure if that's the best way. The querying process can be completely independent, and its only going to occur on scheduled intervals (every 8 hours or so). The user doesn't need to have up to the minute data, so it can take awhile. I just don't want the site to wait for it to finish, if that's possible.

View 1 Replies

Performance - Application Running Slow?

Feb 22, 2011

There's a web app I've been assigned to, which is running very slow. It is a site that sells products so it is database driven, however even pages that do not query the database are loading very slow. The pages use master pages, and the code is in VB.NETI checked with fiddler and the time it takes to load basic (non database driven) pages are about 5.5 seconds on average.

What are some tools that can help me determine the cause of the slow speeds, and any recommendations as to how to speed it up, or potential issues that could cause it?UpdateSo I messed around with the code piece by piece as I wasn't getting anywhere with these tools. As soon as I remove master pages, and I include the same code that's on the master pages in the .aspx page itself, the speed improves drastically (approximately 5 times faster load times).What might cause the master pages to cause load times to slow down so much?

View 4 Replies

Cross-thread Operation Not Valid: Accessed From A Thread Other Than The Thread It Was Created On

Apr 2, 2010

I want to remove checked items from checklistbox (winform control) in class file method which i am calling asynchronously using deletegate. but it showing me this error message:-

Cross-thread operation not valid: Control 'checkedListBox1' accessed from a thread other than the thread it was created on.

i have tried invoke required but again got the same error. Sample code is below:

[code]....

View 1 Replies

Keep Timer Running In The Background?

Jan 21, 2010

I was thinking to create a timer to display the elapsed time for a long running task in my asp.net application. I was able to create the timer to run using javascript but i have a problem with it, that is, how can i maintain the elapsed time so that even the user navigate away from the page, the timer will still running and when user return to that page again, he/she still can see the timer running. Beside that, another user that access that page from another computer will also see the timer running. How i can achieve this??

View 1 Replies

Running A .NET Program As A Background Service?

Nov 23, 2010

Here is the simple scenario that I want to apply; There is a .NET application(console or windows) appA and this code updates a large global variable(+50MB) in the project every 30sec. I have another application appB which is a .NET web application and I want to be able to access the updated value of global variable in appA from appB whenever I want.

View 3 Replies

Respond To FTP Upload / Have A Process Running All The Time In The Background

Oct 18, 2010

I want to be able to run an ASP.NET application when a file is upload via FTP. I understand how to use the filewatcher class to monitor the directory but I don't know where to put the code so it is always running.

Files will be uploaded once per month for each group of users of the system and the next time the user logs on after the upload I would like the application to reflect the new data. I don't want to check for a new upload when each user logs on because the processing could take a log time.

The uploads are automatic from multiple other computer systems and not done by any user.

The Application is hosted (by GoDaddy) so I don't have full control of the server.

Is there any way to have a process running all the time in the background and if so how? The application is written in VB.net.

View 1 Replies

Configuration :: Running Com / Application In Background Without User Logged In?

Aug 3, 2010

I have a web application that initializes a third-party com application to perform few calculations. The website is deployed on a windows 2008 server (standard edition).

The problem I have been facing is that when I am logged in to the server (Remote Desktop Connection only as the server is not local), the com application initializes fine. But when I log-off or just close the remote desktop connection, the application doesn't get initialized. I have searched for a solution and found this:
[URL]

I created the scheduled task as I didn't know how to create the windows service (the description at
http://support.microsoft.com/kb/251192 is too confusing), and got the application to run when windows starts before even the user logs-in. But in even in this case, the application doesn't work unless the user is logged in and when I log-in, a second instance is created (with exactly the same user (admin)) and the original instance is never used.

I cannot get the application to run without logging off or atleast having to close the remote desktop connection.Is there anything I am doing wrong?

View 1 Replies

Save User Credentials On Server For Running Queries In Background?

Apr 1, 2011

We have an ASP.NET / Silveright web application. The silverlight client displays user specific data in a graphical form - it requests the data from the server: Problem: Getting this data is expensive, due to the underlying database queries that the server has to perform - so the client has to wait... Optimisation Idea: We run the database queries at regular intervals on the server, writing the results to a 'userdata' table in a database 'close' to where the ASP.NET server runs. The process of running the queries and writing the data to the tables is performed by a 'data collection' service, which is separated from the ASP.NET server.

When the client requests data the server retrieves it from a 'userdata' table. This should be nice and quick - we probably have the 'userdata' tables on the same machine as the ASP.NET server. We also have the added benefit that the client sees data even if the underlying database is offline. Of course the data is not live - but all data is potentially old as soon as it reaches the client. So now my Problem: The 'data collection' service needs the user credentials in order to perform these database queries (because each user gets different results for the same query).

How can I store user credentials in a database, in an acceptable 'secure' way? Such that the 'data collection' can impersonate a user to perform the database queries. Our initial scenario is based upon using windows integrated login to the database.

View 1 Replies

How To Ensure Background Thread Ends When Application Ends?

Aug 12, 2010

I have an asp.net application with a background thread. The thread starts when the application starts and it is gracefully stopped when the application ends. I am running the website on a shared host. Unfortunately sometimes the application does not trigger the Application_End event when it ends. I would think that the threads would be killed anyway, but that's not the case. I currently have 4 threads running in the background. Three from previous times the application started and 1 from the current application session. How can I ensure that the threads are shutdown when the application ends? Is there a way for the threads to check if the application was reset or had been reset? Or is there a way to check for these rogue threads at application startup and kill them?

View 1 Replies

AJAX :: How To Update Label When We Are Processing Code In The Background For Long Running Process

Aug 25, 2010

I have Requirement to update the label text as we are processing the code (Long running).

Example:

I have Label and button on aspx page.

On button Click Iam calling the AppCode which is going to do long work for me.

I want to update the label text from the appcode (which should reflect in the page then and there.)

I have tryed to pass the text value to the label but it shows the changed text only after the event for the button click is finished.

I tryed using timer but as soon as i click the button the refreshing stops.

I tryed progress template and UpdateProgress without success. (I know we can update at the start and end of proccess using this)

I dont want to use iframe (I know we can do using iframe)

View 3 Replies

Visual Studio :: Debug A Multi Thread Program To See Local Variables Of Each Thread Using 2008

Jan 27, 2010

How can we debbug a multi-thread program to see local variables of each thread using visual studio 2008.

View 1 Replies

Architecture :: How Can Thread Update A Variable Shared With The Main Thread

Nov 24, 2010

I'm new to threading and have used it successfully, but limited. I can spawn a thread and have the main thread reference variables in the spawned thread, but I don't know how to allow the spawned thread to reference (and update) variables in the main thread.

Any example threading code I've seen on the web appears to be WAY more complicated than what I do, so I am unable to understand or integrate into my code.

Here is a quick example of how I use threading:

[code].....

View 3 Replies

What Are The Differences Between Currently Executing .NET Thread And Win32 Thread

Mar 24, 2010

I am reading the Asp.net security documentation on msdn.I come across these tow terms and get really confused.

# WindowsIdentity = WindowsIdentity.GetCurrent()

which returns the identity of the security context of the currently executing Win32 thread.

# Thread = Thread.CurrentPrincipal

which returns the principal of the currently executing .NET thread which rides on top of the Win32 thread.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved