Unanswered: Not waiting for a Stored Procedure to Finish
I have a Stored Procedure which Ideally should run when a Customer Logs in, the Procedure will check the available stock and create a Temp Table for the Information, which allows many other Queries in the site to run a lot faster, (due to no joins). The Query has taken as much as 30seconds (Lots of Records and 1/2 dozen Joins) to run upon log in and causing a Timeout for the web application.
I want the procedure to run as it is, but for the login method to not be dependent on the Process tried this in .NET cmd.BeginExecuteNonQuery() (cmd=SQLCOmmand)
which doesn't do what I want it just allows me to run heaps of QUeries at the same time.
Can anyone help me with getting this procedure to run and not hold up the Web application? Not sure whether I need to do this in .NET, or whether I can get .NET to run a Batch File or something, but someone must have had a similiar problem, please help.
Public Class TaskInfo
Public Conn As SqlConnection
Public CustomerID As Integer
Public Sub New(ByVal Connect As SqlConnection, ByVal ID As Integer)
Conn = Connect
CustomerID = ID
Public Sub UpdateTempDetails_ForCustomerWebQuote(ByVal info As Object)
'This should only be used for updates,
'see webservices for other options
Dim ti As TaskInfo = CType(info, TaskInfo)
Dim cmd As New SqlCommand("UpdatePartTypeDetailsTable", ti.Conn)
cmd.CommandType = CommandType.StoredProcedure
Dim count As Integer = 0
Dim result As IAsyncResult = cmd.BeginExecuteNonQuery()
While Not result.IsCompleted
' Wait for 1/10 second, so the counter
' does not consume all available resources
' on the main thread.
count += 1
Yeah fair call made some changes use to say 100,
While your paying attention, is there anything I should be concerned about memory usage of ThreadPool.QueueUserWorkItem, have had a look round couldn't find anything?