開啟/etc/init.d下的Script ,找到下面這句:
#chkconfig: 2345 64 36
2345是啟動的環境
64是啟動的順序
36是關機的順序
改變後執行下面的命令就完成了:
#chkconfig --del servicename
#chkconfig --add servicename
#chkconfig servicename on
private void RunSample01()
{
Console.WriteLine("執行緒:{0}",Thread.CurrentThread.ManagedThreadId);
}
ThreadStart myRun = new ThreadStart(RunSample01);
Thread myThread = new Thread(myRun);
myThread.Start();
private void button2_Click(object sender, EventArgs e)
{
//1.建立ThreadStart委派
ThreadStart myRun = new ThreadStart(RunSample01);
for (int i = 0; i < 6; i++)
{
try
{
//2.建立Thread 類別
Thread myThread = new Thread(myRun);
//3.啟動執行緒
myThread.Start();
}
catch (Exception)
{
//例外發生則終止迴圈執行
break;
}
}
}
private void button3_Click(object sender, EventArgs e)
{
//1.建立ParameterizedThreadStart委派
ParameterizedThreadStart myPar = new ParameterizedThreadStart(RunSample02);
//2.建立Thread 類別
Thread myThread01 = new Thread(myPar);
Thread myThread02 = new Thread(myPar);
//3.啟動執行緒並帶入參數
myThread01.Start("我是多執行緒第一號");
myThread02.Start("我是多執行緒第二號");
}
private void RunSample02(object o)
{
string myStr = o as string;
//string myStr = (string)o;
if (myStr == null)
{
myStr = (string)o;
}
else
{
for (int i = 0; i < 6; i++)
{
Console.WriteLine("{0}:{1}", myStr, Thread.CurrentThread.ManagedThreadId);
Thread.Sleep(1000);
}
}
}
private delegate void myUICallBack(string myStr, Control ctl);
private void myUI(string myStr, Control ctl)
{
if (this.InvokeRequired)
{
myUICallBack myUpdate = new myUICallBack(myUI);
this.Invoke(myUpdate, myStr, ctl);
}
else
{
ctl.Text = myStr;
}
}
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
}
}