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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:55:53+00:00 2026-05-26T11:55:53+00:00

So im trying to make a data-grid that displays some information about local window

  • 0

So im trying to make a data-grid that displays some information about local window services, mine in particular, I would like to have the display name and status of the service, and then have a button to click to start or stop. I can link the button method up fine, but the service status does not change, any suggestions an how to make this property observable to the datagrid, and also possible change the button on the fly from start to stop based on the status, secondly I would like to make the stop command be be a button command if possibe.

Any suggestions?

  • 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-26T11:55:54+00:00Added an answer on May 26, 2026 at 11:55 am

    This is what I ended up implamenting. It works pretty well for the most part, however I up for any code suggestions anyone might.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using System.ServiceProcess;
    
    namespace v7quickbar
    {
        class NotifiableServiceController : INotifyPropertyChanged
        {
    
            private ServiceController m_oServiceController = null;
            private System.Timers.Timer m_oServiceCheckTimer = new System.Timers.Timer();
    
            public ServiceControllerStatus Status { get { return this.m_oServiceController.Status; } }
    
            public string DisplayName { get { return this.m_oServiceController.DisplayName; } }
    
            public string ServiceName { get { return this.m_oServiceController.ServiceName; } }
    
            public bool CanStop { get { return this.m_oServiceController.CanStop; } }
    
            public NotifiableServiceController(ServiceController oService)
            {
                CreateObject(oService, TimeSpan.FromSeconds(.5));
            }
    
            public NotifiableServiceController(ServiceController oService, TimeSpan oInterval)
            {
                CreateObject(oService, oInterval);
            }
    
            private void CreateObject(ServiceController oService, TimeSpan oInterval)
            {
                m_oServiceController = oService;
                m_oServiceCheckTimer.Interval = oInterval.TotalMilliseconds;
    
                m_oServiceCheckTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_oServiceCheckTimer_Elapsed);
                m_oServiceCheckTimer.Start();
            }
    
            public void Start()
            {
                try
                {
                    this.m_oServiceController.Start();
                    this.m_oServiceController.WaitForStatus(ServiceControllerStatus.Running);
                }
                catch (Exception)
                {
                }
            }
    
            public void Stop()
            {
                try
                {
                    this.m_oServiceController.Stop();
                    this.m_oServiceController.WaitForStatus(ServiceControllerStatus.Stopped);
                }
                catch (Exception)
                {
                }
            }
    
            public void Restart()
            {
                try
                {
                    if (m_oServiceController.CanStop && (m_oServiceController.Status == ServiceControllerStatus.Running || m_oServiceController.Status == ServiceControllerStatus.Paused))
                    {
                        this.Stop();
                        this.m_oServiceController.WaitForStatus(ServiceControllerStatus.Stopped);
                    }
    
                    if (m_oServiceController.Status == ServiceControllerStatus.Stopped)
                    {
                        this.Start();
                        this.m_oServiceController.WaitForStatus(ServiceControllerStatus.Running);
                    }
                }
                catch (Exception)
                {
                }
            }
    
            void m_oServiceCheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
            {
                ServiceControllerStatus oCurrentStatus = m_oServiceController.Status;
                m_oServiceController.Refresh();
    
                if (oCurrentStatus != m_oServiceController.Status)
                {
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Status"));
                }
    
            }
    
            public static IEnumerable<NotifiableServiceController> GetServices()
            {
                List<NotifiableServiceController> oaServices = new List<NotifiableServiceController>();
                foreach (ServiceController sc in ServiceController.GetServices())
                {
                    oaServices.Add(new NotifiableServiceController(sc));
                }
    
                return oaServices;
            }
    
            public event PropertyChangedEventHandler PropertyChanged;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make sure some data is auto-deleted when there's no more references
Trying to make a custom :confirm message for a rails form that returns data
I'm trying to make a script that automatically starts uploading after the data has
I am trying to make an app that will pass data between two servers
I'm trying to make a WPF UIElement that does some special rendering. The problem
I am trying to make a data binded grid template in Silverlight for WP7
I'm trying to make something that looks like: http://dev.sencha.com/deploy/ext-3.4.0/examples/grid/edit-grid.html But I want to change
I'm trying to make data grid with paging using ExtJs framework, but unfortunately my
I'm trying to make a data bound column invisible after data binding, because it
I'm trying to inherit QSqlTableModel to make data im my table display in way

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.