Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8246967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:41:03+00:00 2026-06-07T22:41:03+00:00

I am creating a Windows Server which will install itself on dobleclick. But i

  • 0

I am creating a Windows Server which will install itself on dobleclick. But i am writing the core code. The problem i am facing is

The windows Server will fetch 10 records from database and upload using a WCF Service.
Now after the completing of these 10 records, the service will again look into database and take again 10 records.

But i am also using Timer so that this process will continue every after 5 minutes. Now if at certain time, this upload using WCF took more than 5 Minutes, i have to stop the new execution and wait until it is complete.

How can i perform.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:41:05+00:00Added an answer on June 7, 2026 at 10:41 pm

    This is an ideal scenario for locking. In the below example the callback will trigger every 5 minutes. If the service is still processing a previous batch when the next callback triggers it will simply discard it and try again in 5 minutes time. You can change this to have the callbacks queue up if you prefer, however, you would need to be wary of thread pool starvation if you queue too many.

    You could even reduce your interval to say 1 minute to avoid any long delays in the scenario where a batch runs over.

    static Timer timer; 
    static object locker = new object(); 
    
    public void Start() 
    { 
        var callback = new TimerCallback(DoSomething); 
        timer = new Timer(callback, null, 0, 300000); 
    } 
    
    public void DoSomething() 
    { 
        if (Monitor.TryEnter(locker)) 
        { 
           try 
           { 
               // my processing code 
           } 
           finally 
           { 
               Monitor.Exit(locker); 
           } 
        } 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a Windows service which will depend on the SQL Server service having
I am writing a windows service which will communicate to a user level application.
I'm creating a Windows application which reads XML file from given server. This application
I am creating a Flex project on my Windows machine but it will deploy
I am creating a windows phone application, which need to store some data in
I'm creating a windows service that will let different users connect to the PC
I am creating a windows application using VB.Net and this application will take a
I'm creating a Windows app that automatically updates itself. I'm not using ClickOnce for
i need to write a socket server using perl which will run on a
I'm looking for a python library for easily creating a server which exposes web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.