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 340881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:39:27+00:00 2026-05-12T10:39:27+00:00

Hi I have created a little application to move some files around and put

  • 0

Hi I have created a little application to move some files around and put them into a database. This is working well except that the application needs a timeout.

If my app has not completed the task within 2 hours it re opens and locks out everything. I need to say that if my application has been open for 2 hours close it.

One thought was can you set a time out in an application. I have had a google for this and found some stuff in system.threading about timeout=infinite and threading.sleep=200 but don’t really understand this.

Another thought, is using the timer and counting up to 2 hours and then calling a close method, this seams like a bit of a cheat.

Any ideas on time out in either C# or Vb


Sadly this is not for a db connection this is not where the application is failing.

  • 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-05-12T10:39:27+00:00Added an answer on May 12, 2026 at 10:39 am

    What about allowing just one instance of your application to run at the same time?

    I guess you are scheduling runs: have a look at this code as a way of preventing multiple instances of your application without changing the scheduling.

    static void Main(string[] args)
    {
        Mutex flag = new Mutex(false, "UNIQUE_NAME");
        bool acquired = flag.WaitOne(TimeSpan.FromMilliseconds(0));  // 0 or more milliseconds
        if (acquired)
        {
            Console.WriteLine("Ok, this is the only instance allowed to run.");
    
            // do your work, here simulated with a Sleep call
            Thread.Sleep(TimeSpan.FromSeconds(5));
    
            flag.ReleaseMutex();
            Console.WriteLine("Done!");
        }
        else
        {
            Console.WriteLine("Another instance is running.");
        }
        Console.WriteLine("Press RETURN to close...");
        Console.ReadLine();
    }
    

    Please, don’t abandon your Mutex… 😉

    HTH

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i got a little application which is working very well with my debug configuration
I have created a little application to convert XML which I get out of
I have written a little console application that uses s#arp. I can create an
I have created a little test project to try to resolve a problem I
I have created a little example,please have a look, http://jsfiddle.net/bWTwL/ I want to have
Ok, I have created a little utility with AppleScript and used Automator to turn
I am a little stuck. I have created almost everything in the picture below.
I have a page which contains a jQuery-UI horizontal slider, created using a little
I'm a jQuery newbie, and I have trouble with a little script I created.
I have only a little question: Why the CFPreferences-API creates multiple files in my

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.