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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:49:47+00:00 2026-05-15T09:49:47+00:00

I have been task with (ha) creating an application that will allow the users

  • 0

I have been task with (ha) creating an application that will allow the users to schedule a command line app we have with a parameter.

So the command line app takes an xml and “runs it”

So bottom line I either need to create a windows service or learn how to interact with the Task Scheduler service already running on the box (version 1 Xp /2003)

At first I though it would be easy have a service run and when a job is submitted, calculate the time between now and run and set up a timer to wait that amount of time. This is better then checking every minute if it’s time to run.

Were I hit a wall is I relized I do not know how to communicate with a running windows service. Except maybe create a file with details and have the service with a file watcher to load the file and modify the schedule.

So the underlying questions are how can I execute this psedo code

from client

 serviceThatIsRunning.Add(Job)

Or ineracting with the task schedule or creating .job files using c# 3.5

Edit:

To clarify I created a small sample to get my thoughts on “paper”

So I have a Job Class

public class Job
{
    #region Properties
    public string JobName { get; set; }
    public string JobXML { get; set; }
    private Timer _JobTimer;
    public Timer JobTimer
    {
        get
        {
            return _JobTimer;
        }
    }

    #endregion

    public void SetJobTimer(TimeSpan time)
    {
        if (_JobTimer != null)
        {
            _JobTimer.Dispose();
        }

        _JobTimer = new Timer(new TimerCallback(RunJob), null, time, time);

    }

    private void RunJob(Object state)
    {
        System.Diagnostics.Debug.WriteLine(String.Format("The {0} Job would have ran with file {1}", JobName, JobXML));
    }

    public override string ToString()
    {
        return JobName;
    }

    public void StopTimer()
    {
        _JobTimer.Dispose();
    }
}

Now I need to create an App to house these Jobs that is constantly running, that is why I though of Windows Services, and then a Windows app to allow the user to work with the Job List.

So the question is if I create a Windows Service how do I interact with methods in that service so I can change the JobList, add, delete, change.

Here is a small windows app I created to show that the Job class does run. Interesting point, If I am doing this correctly, I do not add the Job to a listbox and the Add method exits the Job Timer portion still runs and does not get picked up by the Garbage Collector.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void btnAddJob_Click(object sender, EventArgs e)
    {
        Job job = new Job();

        job.JobName = txtJobName.Text;
        job.JobXML = txtJobXML.Text;
        job.SetJobTimer(new TimeSpan(0, 0, Convert.ToInt32(JobTime.Value)));

        // ??Even If I don't add the Job to a list or ListBox it seems 
        // ??to stay alive and not picked up by the GC            
        listBox1.Items.Add(job);
    }

    private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (listBox1.SelectedIndex > -1)
        {
            Job job = listBox1.Items[listBox1.SelectedIndex] as Job;

            txtJobName.Text = job.JobName;
            txtJobXML.Text = job.JobXML;
        }

    }

    private void btnRemove_Click(object sender, EventArgs e)
    {
        Job job = listBox1.Items[listBox1.SelectedIndex] as Job;
        job.StopTimer();
        listBox1.Items.Remove(job);
    }

    private void btnCollect_Click(object sender, EventArgs e)
    {
        GC.Collect();
    }
}
  • 1 1 Answer
  • 1 View
  • 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-15T09:49:48+00:00Added an answer on May 15, 2026 at 9:49 am

    There was an answer on this thread that is no longer there but, I am going to try to create a listener by keeping a port open

    WCF through Windows Services
    http://msdn.microsoft.com/en-us/library/ms733069.aspx

    Also adding the attribute

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    

    Helps to keep state of the service.

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

Sidebar

Related Questions

I have been assigned wit the task to write a program that takes a
I have been given the task of devising a custom forms manager that has
I have been given the task of converting a macromedia application to a web
I have been given a new task from the client which is basically creating
I have been task with the mission of creating a phone solution where clients
I have been given the task of creating a sql database and creating a
For my assignment I have been assigned the task of creating a DTD for
I have been assigned the task of creating some graphical stats for a website,
I have been given the task of adding functionality to an existing IIS 6.0
I have been given the task to design a database to store a lot

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.