Using a Thread in a Web Application to Access a Database

Hi. Is it possible to use a thread to interact with a database?

I want to do some logging of user transactions but I don't want to hold up the user while he/she is interacting with the website.

I have found some examples tf using threads in a Windows application, but very little for web-applications.

I really could use an example where a thread starts aparameratized function, and how to set this up.

So far, as a test, I have tried:

Thread t =new Thread(new ThreadStart(Send_Email_Edit_Value));

t.Start(transaction, List_Name, IB_Acct, Current_Acct, Current_Value, strNewValue, Current_Unit, New_Unit);

The function I am trying to start is:

privatevoid Send_Email_Edit_Value(string transaction,string List_Name,string IB_Acct,string Current_Acct,string Current_Value,string strNewValue,string Current_Unit,string New_Unit)

{

this.transaction = transaction;

this.List_Name = List_Name;

this.IB_Acct = IB_Acct;

this.Current_Acct = Current_Acct;

this.Current_Value = Current_Value;

this.strNewValue = strNewValue;

this.Current_Unit = Current_Unit;

this.New_Unit = New_Unit;

string mailTo =address@mail.com;

//do stuff

}

But I get compilation errors:

Send_Email_Edit_Value(string, string, string, string, string, string, string, string)' does not match delegate 'void System.Threading.ThreadStart()'

AND

IB_Data.cs(633): No overload for method 'Start' takes '8' arguments

Any Ideas or sample code?

Thanks in advance,

Frank


[2924 byte] By [Tigris] at [2007-12-24]
# 1
I think you can do that using Async commands in ADO.NET, which allows you to execute something against the DBm and meanwhile you are waiting for the response, you can do some other things. This article will show you how to work with that, including all its advantages and limitations.

Asynchronous Command Execution in ADO.NET 2.0

Good Luck!

LuisD.Rojas at 2007-10-8 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
Thanks very much... from my initial quick scan of the document, it looks like it is exactly what I was looking for.
Tigris at 2007-10-8 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified