• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • 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


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

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

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

    End Sub

    Private Sub PollingPass()
            ' 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 ?
1 Solution
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.
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 .

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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