Exemple #1
0
 public Task <object> StartService(ServiceInfo service)
 {
     return(taskFactory.StartNew <object>(() =>
     {
         NativeServiceInfo native = mapper.Map <NativeServiceInfo>(service);
         nativeServiceOperations.StartService(native);
         UpdateServiceInfo(service, native);
         return null;
     }));
 }
Exemple #2
0
        public async Task <object> RestartService(ServiceInfo service)
        {
            return(taskFactory.StartNew <object>(() =>
            {
                NativeServiceInfo nativeServiceInfo = mapper.Map <NativeServiceInfo>(service);
                if (service.State == ServiceState.Running)
                {
                    nativeServiceOperations.StopService(nativeServiceInfo);
                    UpdateServiceInfo(service, nativeServiceInfo);
                }

                nativeServiceOperations.StartService(nativeServiceInfo);
                UpdateServiceInfo(service, nativeServiceInfo);
                return null;
            }));
        }
Exemple #3
0
 void UpdateServiceInfo(ServiceInfo serviceInfo, NativeServiceInfo actualInfo)
 {
     serviceInfo.Id    = actualInfo.id;
     serviceInfo.State = (ServiceState)actualInfo.state;
 }