private void listViewServices_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//获取服务的运行状态
ServiceController[] MyServices = ServiceController.GetServices();
//将服务的名称添加到ListBox中
for (int i = 0; i < MyServices.Length; i++)
{
string state = MyServices[i].Status.ToString();
switch (state)
{
case "Stopped":
lblState.Content = "服务已停止";
btnRestart.IsEnabled = false;
btnStart.IsEnabled = true;
btnStop.IsEnabled = false;
continue;
case "Running":
lblState.Content = "服务运行中";
btnStart.IsEnabled = false;
btnStop.IsEnabled = true;
btnRestart.IsEnabled = true;
continue;
case "StartPending":
lblState.Content = "服务正在启动";
continue;
case "StopPending":
lblState.Content = "服务正在停止";
continue; } }
这是控制windows服务启动停止的判断,现在是一运行选中列后就直接运行到case "Running": 再点击其他的列也不改变,哪里有问题啊,谢谢
{
//获取服务的运行状态
ServiceController[] MyServices = ServiceController.GetServices();
//将服务的名称添加到ListBox中
for (int i = 0; i < MyServices.Length; i++)
{
string state = MyServices[i].Status.ToString();
switch (state)
{
case "Stopped":
lblState.Content = "服务已停止";
btnRestart.IsEnabled = false;
btnStart.IsEnabled = true;
btnStop.IsEnabled = false;
continue;
case "Running":
lblState.Content = "服务运行中";
btnStart.IsEnabled = false;
btnStop.IsEnabled = true;
btnRestart.IsEnabled = true;
continue;
case "StartPending":
lblState.Content = "服务正在启动";
continue;
case "StopPending":
lblState.Content = "服务正在停止";
continue; } }
这是控制windows服务启动停止的判断,现在是一运行选中列后就直接运行到case "Running": 再点击其他的列也不改变,哪里有问题啊,谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货