Multithreading/Database Polling in Windows Service

Posted on 2012-09-22
Last Modified: 2012-12-16
Poll database table, looking for items to process
Queuing items for processing
Process files on disk (the database table being polled describes the files being processed (file path, processing status))
Record processing results to database

The processing time for each item is assumed to take a long time (hours), so processing should take place on its own thread and multiple items should be processed concurrently (though probably not all items in the queue if the queue has a lot of items).

I'm not an expert
Question by:afifosh
    LVL 50

    Expert Comment

    by:Julian Hansen
    What's the question?
    LVL 1

    Accepted Solution

    the procces who i can do this ? using c# and thread ..
    u can take a look for this code

    this my first time on windows app and i want to write a service can read and process record from table

    and after finish it i repeat the job again using c# ?

    and if the code is that why i need tell me where i will insert my  sql connection and add begin transaction
    LVL 50

    Expert Comment

    by:Julian Hansen
    Ok so what you are are asking is for someone to provide the code that does the above - is that correct?

    It seems the basics are in the CodeProject article - what is missing that you need?
    LVL 1

    Author Comment

    what i need is i have a table on database where i store on it  all task added by user from web applicaitonn

    so my application should be run as windows service and do the task
    the task is

    some sql query
    select the record update status of record to begin processing
    insert data on new table
    select some record and post to an url

    use transaction on query if the sql query didn\t committed rollback it to original state
    to re process it again..

    when i finish and my all my query and post url .. update the status to DONE
    to prevent read it again ..

    than i want to repeat this jobs when he finish

    1- run windows service
    2- do a job
    3- wait sleep 30 second
    4- repeat the same job

    because the job it will select record from the database

    and my table all time i have new record !!
    LVL 1

    Author Closing Comment

    still now i didn't get any solution maybe no one understand what i mean with my question and still now i don't need to solve it because is too late

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now