• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 527
  • Last Modified:

thread pooling

i have a table. who have always new record on it
so i want to process all record when i process it i change the status of record field to begin processing and when i finish i update the status to done
i have read some topics and they talk about thread and time.. and pooling

the default value of status of task is "to process"
do a task ! like select top (100) from table where status = "to process"
than i update the status to begin process .
insert in other table
update status to done
i want to use transction begin and end and rollback if my job not committed it will be rollback  i don\t know about how to it on c# and mssql ..


than sleep to 30 second.. after fetch all top 100 row and do my job slelect update insert

than i repeat it always. i want to run it as windows services.

can any one check tthis code and tell me if it was i try to doo

http://www.codeproject.com/Articles/16615/How-to-Create-a-Simple-Polling-Service

  Private Sub PollProcess()
        ' Loops, until killed by OnStop.

        EventLog1.WriteEntry("PollingService service polling thread started.")
        Do
            ' Wait...

            System.Threading.Thread.Sleep(30000) ' 30000 = 30 seconds


            PollingPass()
        Loop
    End Sub

    Private Sub PollingPass()
        Try
            ' Do Stuff Here...

            EventLog1.WriteEntry("PollingService service polling pass executed.")
        Catch ex As System.Exception
            EventLog1.WriteEntry("PollingService encountered an error '" & _
                ex.Message & "'", EventLogEntryType.Error)
            EventLog1.WriteEntry("PollingService service Stack Trace: " & _
                ex.StackTrace, EventLogEntryType.Error)
        End Try
    End Sub






            ' Do Stuff Here...
here i wil but my sql query????


and i want some one tell me if this app  do a a stuff when the stuff finish ... sleep 30 second and repeat the same jobbbbbbbbbbb???????????/

i need to do like this ?
0
afifosh
Asked:
afifosh
1 Solution
 
apeterCommented:
Use a system.threading.timer control and set it timespan to 30 seconds.

When the timer method is called , first you disable your timer so it doesn't trigger again.

Do you select, insert etc

Finally you enable th timer, so that it waits for 30 seconds and triggers.
0
 
Saurabh BhadauriaCommented:
Why don't you use SQL server JOBS .. They are quite efficient to do this kind of functionality.
Check below link . you can write your logic with in SP and can call that SP through a job .


http://databases.about.com/od/sqlserver/ss/sql_server_agent_2.htm
http://databases.about.com/od/sqlserver/ss/sql_server_agent_3.htm
http://msdn.microsoft.com/en-us/library/ms187910.aspx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now