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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:25:21+00:00 2026-06-01T17:25:21+00:00

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Linq; using System.ServiceProcess;

  • 0
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.IO;
using System.Collections;

namespace cloud_sync
{
public partial class cloud_sync : ServiceBase
{
    public cloud_sync()
    {
        InitializeComponent();
    }

    protected override void OnStart(string[] args)
    {
        while (true)
        {
            System.Diagnostics.Process proc = new System.Diagnostics.Process();

            proc.StartInfo.FileName = "C:\\ec2\\ec2.bat";
            proc.StartInfo.RedirectStandardError = false;
            proc.StartInfo.RedirectStandardOutput = false;
            proc.StartInfo.UseShellExecute = true;
            proc.Start();
            proc.WaitForExit();

            string[] filePaths = Directory.GetFiles(@"c:\My cloud\VM Instances\");
            foreach (string filePath in filePaths)
                File.Delete(filePath);
            try
            {
                StreamReader sr = new StreamReader("c:/ec2/temp.txt");

                if (new FileInfo("c:/ec2/temp.txt").Length > 0)
                {
                    string line, temp, temp1;
                    string[] content = new string[4];
                    line = GetWord(sr);
                    line = GetWord(sr);
                    string[] terms = line.ToLower().Trim().Split('\t');

                    Console.WriteLine(terms[1]);
                    Console.WriteLine(terms[5]);
                    Console.WriteLine(terms[9]);
                    temp1 = terms[1];
                    content[0] = "Instance_id :" + terms[1];
                    content[1] = "Status :" + terms[5];
                    content[2] = "Type :" + terms[9];
                    if (terms[5].Equals("terminated"))
                    {
                        line = GetWord(sr);
                    }
                    else
                    {
                        line = GetWord(sr);
                        line = GetWord(sr);
                    }



                    terms = line.ToLower().Trim().Split('\t');
                    Console.WriteLine(terms[4]);
                    content[3] = "Name :" + terms[4];
                    int i = terms[4].Length;

                    temp = "c:/My cloud/VM Instances/" + temp1 + " (" + terms[4] + ")";
                    temp = temp + ".cvm";
                    File.WriteAllLines(temp, content);


                    while ((line = GetWord(sr)) != null)
                    {
                        line = GetWord(sr);
                        terms = line.ToLower().Trim().Split('\t');

                        Console.WriteLine(terms[1]);
                        Console.WriteLine(terms[5]);
                        Console.WriteLine(terms[9]);
                        temp1 = terms[1];
                        content[0] = "Instance_id :" + terms[1];
                        content[1] = "Status :" + terms[5];
                        content[2] = "Type :" + terms[9];
                        if (terms[5].Equals("terminated"))
                        {
                            line = GetWord(sr);
                        }
                        else
                        {
                            line = GetWord(sr);
                            line = GetWord(sr);
                        }

                        terms = line.ToLower().Trim().Split('\t');
                        Console.WriteLine(terms[4]);
                        content[3] = "Name :" + terms[4];
                        i = terms[4].Length;

                        temp = "c:/My cloud/VM Instances/" + temp1 + " (" + terms[4] + ")";
                        temp = temp + ".cvm";
                        File.WriteAllLines(temp, content);
                    }
                }
                sr.Close();
                sr.Dispose();
                System.Threading.Thread.Sleep(50000);
                File.Delete("c:/ec2/temp.txt");

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

        }
    }
    protected override void OnStop()
    {
    }

   static string GetWord(StreamReader sr)
    {
        return sr.ReadLine();
    }

}    
}

I have written this system service but when I start this service, it show me error “Windows could not start the cloud_sync service on local computer. Error: 1053 the service did not respond to start and control request in timely fashion. “
and after pressing ok its status become “starting”. Please tell what is the problem with this.
I am greenhorn in c#, this is my first system service.
please help me out of this

  • 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-01T17:25:22+00:00Added an answer on June 1, 2026 at 5:25 pm

    You are receiving Windows could not start the cloud_sync service on local computer. Error: 1053 the service did not respond to start and control request in timely fashion because your OnStart() is not returning. You need to spin off another thread to execute your desired code.

    private Task _serviceTask;
    private bool _stop;
    
    protected override void OnStart(string[] args)
    {
        _serviceTask = Task.Factory.StartNew(SomeTask) 
    }
    
    // Rename the method from SomeTask to something that makes more sense
    private static void SomeTask()
    {
        // Move your code here
    }
    

    You should replace your while(true) to while(!_stop) so that you can gracefully end the loop within OnStop().

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

Sidebar

Related Questions

using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace EfTestFactory { public abstract class
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.ComponentModel; using System.Data;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
This is my problem: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1
I have the following code using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace

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.