コード例 #1
0
 public bool Request(ServiceStatus ss)
 {
     return ss.Control(SC_CONTROL_CODE.SERVICE_CONTROL_CONTINUE);
 }
コード例 #2
0
 public bool Request(ServiceStatus ss)
 {
     return ss.Start();
 }
コード例 #3
0
        private void backgroundWorker1_Process(NativeService ns, ServiceObject so)
        {
            bool requestedStatusChange = false;

            Trace.TraceInformation("BEGIN backgroundWorker1_Process for {0}", ns.Description);

            using (ServiceStatus ss = new ServiceStatus(ns))
            {
                for (int i = 0; i < 100; ++i)
                {
                    if (bCancelled)
                        break;

                    double RelativePercentage = (PercentPerService * (double)i) / 10.0;
                    double Percentage = CurrentPercentage + RelativePercentage;

                    int p = (int)Percentage;
                    if (p >= 100)
                        p = 99;
                    backgroundWorker1.ReportProgress(p);

                    if (!ss.Refresh())
                        break;

                    Trace.TraceInformation("Refresh #{0}: Status is {1}", i, ss.Status.CurrentState);
                    Invoke(new StatusMessageDelegate(StatusMessage), null, ss.Status.CurrentState);
                    if (SSR.HasSuccess(ss.Status.CurrentState))
                    {
                        Trace.WriteLine("Reached target status, done...");
                        break; // TODO: reached 100% of this service' status reqs.
                    }

                    // if we haven't asked the service to change its status yet, do so now.
                    if (!requestedStatusChange)
                    {
                        requestedStatusChange = true;
                        Trace.TraceInformation("Ask {0} to issue its status request on {1}", SSR, ss);
                        if (!SSR.Request(ss))
                            break;
                    }
                    else if (SSR.HasFailed(ss.Status.CurrentState))
                    {
                        Trace.TraceInformation("ERROR, target state is one of the failed ones :(");
                        break;
                    }
                    Thread.Sleep(500);
                }
                ss.Modify(so);
                Trace.TraceInformation("END backgroundWorker1_Process");
            }
        }
コード例 #4
0
 public bool Request(ServiceStatus ss)
 {
     SS = ss;
     HasBeenAskedToStart = false;
     return ss.Control(SC_CONTROL_CODE.SERVICE_CONTROL_STOP);
 }