我正在VB中编写一个小应用程序,我想知道如何设置它,以便当用户按下按钮时,会运行一个sechduled任务。请记住,此任务已经创建,我只需要它就可以运行。
有什么想法吗?
由于
答案 0 :(得分:0)
使用System.Diagnostics.Process类。您可以使用Process.Start()方法创建进程并运行它。
修改强> 下面的代码示例启动helloworld.exe。这只是为了介绍Process类。您可以在Process.Start Method
中找到此示例using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
class MyProcess
{
public static void Main()
{
Process myProcess = new Process();
try
{
myProcess.StartInfo.UseShellExecute = false;
// You can start any process, HelloWorld is a do-nothing example.
myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
// This code assumes the process you are starting will terminate itself.
// Given that is is started without a window so you cannot terminate it
// on the desktop, it must terminate itself or you can do it programmatically
// from this application using the Kill method.
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
答案 1 :(得分:0)
如何使用最近添加的System.Threading.Tasks库?
链接:http://msdn.microsoft.com/en-us/library/system.threading.tasks.aspx