如何在C#中为Windows应用程序显示进度条,以获取具有未知处理时间的Windows服务? [英] How to show progress bar on a windows application in C# for a windows service having unknown process time?
本文介绍了如何在C#中为Windows应用程序显示进度条,以获取具有未知处理时间的Windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在C#中为Windows应用程序显示进度条以获取具有未知处理时间的Windows服务?
我正在使用Windows应用程序,其中有一个运行用于启动服务的按钮和停止按钮以便停止服务。
此处可能需要更短更长的时间。
以下是我的C代码#
How to show progress bar on a windows application in C# for a windows service having unknown process time?
I am using a windows application where there is a Run Button to start the service and Stop Button inorder to stop the same.
Here Process may take shorter and longer time which depends.
Below is my Code in C#
#region btnRun_Click
//Automate the service on clicking Run Button
private void btnRun_Click(object sender, EventArgs e)
{
//To show service started message on button click(Status formload boolean varaiable set)
formload = false;
StartServiceCheck();
}
#endregion
#region StartServiceCheck Function
//To check whether the Archival Automation is installed or not and if installed start the service
private void StartServiceCheck()
{
startservice = false;
serviceInstallationStatus = AS.CheckServiceInstallation(windowsservice);
//Check Archival Automation is Installed in Services.msc
if (serviceInstallationStatus == true)
{
//Start the Archival Automation installed in Services.msc
startservice= AS.StartService(windowsservice);
if (formload == true)
{
btnRun.Enabled = false;
return;
}
//Check whether the Archival Automation is running and if so Run button will be diabled else Run button will be enabled
if (startservice == true)
{
//Disable the Run Button if Service is Already Running
btnRun.Enabled = false;
//Show message box if the Archival Automation is Already running and to shown only on Run Button Click
MessageBox.Show("Archival Automation is Already Running");
}
//If the Archival Automation is not running
else
{
//Enable the Run Button
btnRun.Enabled = true;
//Message to be shown only on Run Button Click with status formload
if(formload==false)
MessageBox.Show("Archival Automation has been started Successfully");
}
btnStop.Enabled = true;
}
//Message Box if Archival Automation is not Installed
else
{
MessageBox.Show("Archival Automation is Not Installed");
}
}
推荐答案
有几种类型的进度条控件。看看这里:进度条 [ ^ 。您想要使用的那个取决于您的需求。我建议你使用带有选框(或动画图像)的进度条;)
There is several types of progress bar control. Have a look here: Progress Bars[^]. The one you want to use depends on your needs. I'd suggest you to use progress bar with marquee (or animated image) ;)
嗨检查他喜欢
在Windows窗体应用程序中显示进度条 [ ^ ]
http://msdn.microsoft.com/en-in/library/windows/apps/hh465469.aspx [ ^ ]
http:// www .aspdotnet-suresh.com / 2010/12 / how-to-use-progressbar-control-in.html [ ^ ]
hi check he likns
Show progress bar in windows forms application[^]
http://msdn.microsoft.com/en-in/library/windows/apps/hh465469.aspx[^]
http://www.aspdotnet-suresh.com/2010/12/how-to-use-progressbar-control-in.html[^]
嗨Rahul,
Progressbar有一种不确定流程的风格。 />
Hi Rahul,
Progressbar has a style for indetermined processes.
myProgressBar.Style = ProgressBarStyle.Marquee;
这篇关于如何在C#中为Windows应用程序显示进度条,以获取具有未知处理时间的Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文