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


Similar Messages:

Thread ID From ThreadPool.QueueUserWorkItem?

May 18, 2010

after invoking an async method using ThreadPool.QueueUserWorkItem how do i lookup the assigned thread id?

View 4 Replies

Signaling Web Page When ThreadPool Thread Is Completed?

Aug 25, 2010

From a web page I start a time consuming job and update it's status on the UI using webmethod.

Job is done in a thread:

ThreadPool.QueueUserWorkItem(new WaitCallback(DoJob), parameters); Job set's it status using static properties, and when web page, using javascript, calls web method it read those properties.

[System.Web.Services.WebMethod]
public static ProcessStatus GetProgressStatus()
{
Jober.Lock.EnterReadLock();
ProcessStatus st = new ProcessStatus(Jober.PercentageCompleted, Jober.TotalNumber);
Jober.Lock.ExitReadLock();
return st;
}

The UI progress is updated through javascript, the problem is that after thread completes I need to update UI on server side, so javascript won't help me here. What Is the best way to signal when thread is completed?

View 1 Replies

Multithreading - .net ThreadPool - Long Running Operation.

Jan 27, 2010

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.

View 3 Replies

Security :: Aspnet Sql Membership / Running On XP IIS Just Fine?

Feb 23, 2010

I have an asp.net site running on XP IIS just fine, with login using aspnetdb. However, I wrote a page that has a datasource that connects to the same db, with a gridview that displays users. I've done this before on 2003 server iis 6 no problem. Here I get,

Cannot open user default database. Login failed.Login failed for user (domainusername)This is the identity I set in IIS 6.0 under authentication methods for anonymous access. I had to do this because the site connects to a remote accessdb as well. I cant use a local account or aspnet account.I dont understand how I can use the same site to login and out, but not to access this page.This is my asp.net conection string

data source=.SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;user instance=true

The web config has this:

<
add
name="ASPNETDBConnectionString"
connectionString="Data
Source=.SQLEXPRESS;AttachDbFilename=C:InetpubwwwrootApp_DataASPNETDB.MDF;Integrated Security=True;Connect Timeout=30;User Instance=true"
providerName="System.Data.SqlClient"
/>

Thats what the data source uses.Go figure when I remove and add again integrated security true, I can see the page. WHY I DONT KNOW!!!! But I also call membership.deleteuser() with a delete button, NOW THIS FAILS!Cannot open user default database. Login failed.Login failed for user '(computername)ASPNET'.

View 4 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

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

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

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

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

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

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

C# - Set HttpContext.Current.User From Thread.CurrentPrincipal?

May 17, 2010

I have a security manager in my application that works for both windows and web, the process is simple, just takes the user and pwd and authenticates them against a database then sets the Thread.CurrentPrincipal with a custom principal. For windows applications this works fine, but I have problems with web applications.

After the process of authentication, when I'm trying to set the Current.User to the custom principal from Thread.CurrentPrincipal this last one contains a GenericPrincipal. Am I doing something wrong? This is my code:

Login.aspx

[code]....

View 5 Replies

C# - Difference Between Http.context.user And Thread.currentprincipal And When To Use Them

Jun 16, 2010

I have just recently run into an issue running an asp.net web app under visual studio 2008. I get the error 'type is not resolved for member...customUserPrincipal'. Tracking down various discussion groups it seems that there is an issue with Visual Studio's web server when you assign a custom principal against the Thread.CurrentPrincipal.

In my code, I now use...

HttpContext.Current.User = myCustomPrincipal
//Thread.CurrentPrincipal = myCustomPrincipal

I'm glad that I got the error out of the way, but it begs the question "What is the difference between these two methods of setting a principal?". There are other stackoverflow questions related to the differences but they don't get into the details of the two approaches.

I did find one tantalizing post that had the following grandiose comment but no explanation to back up his assertions...

[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

C# - Lock Thread.sleep Not Working With .NET Thread?

Jun 25, 2010

I have a password page and when someone enters an incorrect password I want to simply foil a brute force attack by having

bool isGoodPassword = (password == expected_password);

lock (this)
{
if (!isGoodPassword)
Thread.Sleep(2000);
}
I would expect that this would allow all correct passwords without stalling, but if one user enters a bad password another successful password from a different user would also be blocked. However, the lock doesn't seem to lock across ASP.NET threads.

View 4 Replies

Web Forms :: Use Thread.sleep Method For A Particular Thread?

Aug 27, 2010

I want a example of multithreading .i want to use it in a web form not on console.i am using C#.net .and how to use thread.sleep method for a particular thread.

View 5 Replies

Caching - .NET CacheDependency Out Of ThreadPool

Feb 19, 2010

In an async http handler, we add items to the ASP.NET cache, with dependencies on some files. If the async method executes on a thread from the ThreadPool, all is fine:

AsyncResult result = new AsyncResult(context, cb, extraData);
ThreadPool.QueueUserWorkItem(new WaitCallBack(DoProcessRequest), result);

But as soon as we try to execute on a thread out of the ThreadPool:

AsyncResult result = new AsyncResult(context, cb, extraData);
Runner runner = new Runner(result);
Thread thread = new Thread(new ThreadStart(runner.Run());

... where Runner.Run just invokes DoProcessRequest,

The dependencies do trigger right after the thread exits. I.e. the items are immediately removed from the cache, the reason being the dependencies.We want to use an out-of-pool thread because the processing might take a long time.

So obviously something's missing when we create the thread. We might need to propagate the call context, the http context...

Note: off-the-shelf custom threadpools probably solve this. Writing our own threadpool is probably a bad idea (think NIH syndrom). Yet I'd like to understand this in details, though.

View 1 Replies

C# - ThreadPool.QueueUserWorkItem Causes App To Hang Until Finished?

Dec 10, 2010

This may be due to a lack of understanding of what's going on under the hood or simply a lack of understanding of threading in general. When a user logins I need to run some tasks that call web services to update data in my system. Since the services could take a considerable amount of time I thread the entire process. However, even though I think I'm running the whole series of tasks in a thread separate from my application, my application waits until the called function is finished before it proceeds.

WindowsIdentity identity = WindowsIdentity.GetCurrent();
Manager manager = (Manager)Session["Manager"];

ThreadPool.QueueUserWorkItem(new SafeWaitCallback().Call(identity, delegate(object noCallBack)
{
manager.RunAccountUpdater(identity);
}));

The application hangs until the function "RunAccountUpdater" is finished and the callback occurs. What am I doing wrong/not understanding?

View 1 Replies

Using Threadpool.QueueWorkItem In Asnychronous Handler

Mar 28, 2011

This MSDN example for an Asynchronous Handler starts the new thread using ThreadPool.QueueUserWorkItem.

I thought that you should not use ThreadPool.QueueUserWorkItem to start the new thread as the thread is taken from the ASP.net thread pool and defeats the purpose of using an Asynchronous handler.

Is the example wrong?

View 1 Replies

Web Forms :: Implementing The Threadpool Concept And Have Doutbt In Threads Being Created

May 14, 2010

Am implementing the threadpool concept and have doutbt in threads being created.

[Code]....

Initially i gave (1,1) in semaphores and only one thread was created and it did only one task, and (5,5) created one thread and it used for all the times.

Is ter anything wrong in wat i did or any other way of doin other than semaphores. And mainly wat abt the remaining 20 threads in threadpool? its a waste of CPU right. Can i create only 5?

View 6 Replies

ASPNET Locked Out - How To Unlock It

Oct 8, 2010

I have a web service. When called, the web service creates a folder and files on another specified server in our network. When the command executes, I keep getting a crash. Basically, it says the ASPNET account is locked out. I unlock it and try again. Same thing.I tried using impersonate in the web.config, and it still tried to get into the server as ASPNET.The web server hosting the web service has Anonymous access enabled, allows the IIS to control the passworld, and also has intergrated Windows Authentication checked.

View 1 Replies

SQL Server :: ASPNET Membership Tables?

Oct 22, 2010

How can I sync up the aspnet membership tables among 2 different databases?

View 1 Replies

Configuration :: Publish Aspnet.mdf To The Server?

Nov 15, 2010

when i was creatin the website visual studio created the aspnet.mdf automaticly and it was working fine . i could create a new user and login with no problems but after uploading the site content it wont work any more . so my question is how do i susscefly publish the aspnet.mdf file to the server so it would work

View 2 Replies







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