Link to home
Start Free TrialLog in
Avatar of Member_2_6478753
Member_2_6478753Flag for United States of America

asked on

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 ?
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
ASKER CERTIFIED SOLUTION
Avatar of Saurabh Bhadauria
Saurabh Bhadauria
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial