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

  • Home
  • SEARCH
  • 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 1113821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:54:48+00:00 2026-05-17T02:54:48+00:00

static Timer _timer; static void Main(string[] args) { _timer = new Timer(1000); _timer.Enabled =

  • 0
   static Timer _timer;

    static void Main(string[] args)
    {
       _timer = new Timer(1000);
       _timer.Enabled = true;
       _timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

      for (int i = 0; i < 10000; i++)
      {
        string strXMLComperator = @"D:\randomFiles\rand" + i + ".txt";

        if (!File.Exists(strXMLComperator))
        {
          StreamWriter sWriter = new StreamWriter(strXMLComperator, false, Encoding.UTF8);
          sWriter.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?><catalog>dasd</catalog>");
          sWriter.Flush();
          sWriter.Close();
          sWriter.Dispose();
        }
      }
    }   



     private static void OnTimedEvent(object source, ElapsedEventArgs e)
     {
       //some code here
     }

i want to know will Main() Method add files when OnTimedEvent works or it will stop working while timer_event finish

  • 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-17T02:54:49+00:00Added an answer on May 17, 2026 at 2:54 am

    Well, you haven’t said which Timer class you’re using, but assuming you’re not using the Windows Forms timer, then yes: the OnTimedEvent method will be called in a different thread to the Main thread (a thread-pool thread, actually), so they’ll run concurrently.

    (Note that contrary to your question title, this isn’t a different process – just a different thread.)

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

Sidebar

Related Questions

static readonly System.Timers.Timer _timer = new System.Timers.Timer(); static void Main(string[] args) { _timer.Interval =
Given the following RX code: static void Main(string[] args) { int x = 0;
Java code: import javax.swing.Timer; class Main { public static void main(String args[]) { MyListener
import org.joda.time.LocalDate; public class Test { public static void main(String[] args) { long time=System.currentTimeMillis();
In my computer this code takes 17 seconds (1000 millions times): static void Main(string[]
Here is the code: class Time { public static void printTime (int hour, int
I get a compile time error on countList method. public static void countList( List<?
I have a static timer class which will be called by ANY webpage to
I created a Timer private static AutoResetEvent autoEvent; private static Timer stateTimer; public static
I'm trying to dynamically create a connection string during compile time: private static string

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.