Results 1 to 14 of 14

Thread: Thread.Sleep or Timer in a web service - which is proper??

Hybrid View

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Thread.Sleep or Timer in a web service - which is proper??

    My clients are complaining about having to hit a SAVE button - used to enter data in a VB6 msflexgrid and I would autosave at the end of each row!

    They are going to complain that the report doesn't just download automatically - why do they have to click the PRINTER ICON to start a report and then wait until it says it's ready to download - and "what do you mean I've got to click DOWNLOAD?!!?!??!".

    When you write custom software for clients - and want to get paid the best $$'s - they are always right. Customer is always right

    Initial use will be dozens of users - running several reports a day.

    But I've got clients with 100's and even one with 1000+ users with the old VB6 app - when we migrate them things are going to have to scale.

    At this point I've tested this code - and my CPU on my development machine does not go crazy. I do not want to use a TIMER as that starts on another thread and that seems really dangerous in IIS as it's got it's own threading issues to deal with. I'm going to move the DB CONNECTION OPEN outside the loop - no reason to open/close a connection 20 times in a loop...

    Code:
    If ctrloption = "reportstatus" Then 
        Try 
            Dim maxloop As Integer = 20 
            Dim curloop As Integer = 0 
            Do While strMessage <> "C" And curloop < maxloop 
                Using dcn As New SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings("LocalSQLServerAWC").ToString) 
                    Using cmd As New SqlCommand 
                        cmd.CommandType = CommandType.StoredProcedure 
                        cmd.CommandText = "dbo.awc_ReportGetStatus" 
                        cmd.Connection = dcn 
                        cmd.CommandTimeout = 0 
                        DetermineParameters(dcn, cmd) 
                        cmd.Parameters("@RptId").Value = ctrlval1 
                        dcn.Open() 
                        strMessage = cmd.ExecuteScalar().ToString 
                    End Using 
                End Using 
                If strMessage <> "C" Then 
                    curloop += 1 
                    Threading.Thread.Sleep(250) 
                End If 
            Loop 
            .NewObject("reportstatus", "true") 
            .Seperate() 
            .NewObject("rptid", ctrlval1) 
            .Seperate() 
        Catch ex As Exception 
            strSuccess = "" 
            strMessage = ex.Message 
        End Try
    End If

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Thread.Sleep or Timer in a web service - which is proper??

    Quote Originally Posted by szlamany View Post
    I'm going to move the DB CONNECTION OPEN outside the loop - no reason to open/close a connection 20 times in a loop...
    Agreed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width