public Task <object> StartService(ServiceInfo service) { return(taskFactory.StartNew <object>(() => { NativeServiceInfo native = mapper.Map <NativeServiceInfo>(service); nativeServiceOperations.StartService(native); UpdateServiceInfo(service, native); return null; })); }
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; })); }
void UpdateServiceInfo(ServiceInfo serviceInfo, NativeServiceInfo actualInfo) { serviceInfo.Id = actualInfo.id; serviceInfo.State = (ServiceState)actualInfo.state; }