發現不管執行幾個執行緒同時只會有二個連線數存在。
這是.net預設的連線數,透過以下設定即可。
ServicePointManager.DefaultConnectionLimit = 10;網路上有人建議最大連線數不要超過1024,最好的效果是512。
另外也可以從app.config來設定最大連線數
ServicePointManager.DefaultConnectionLimit = 10;網路上有人建議最大連線數不要超過1024,最好的效果是512。
Properties.Settings.Default.myColor = Color.AliceBlue;
Properties.Settings.Default.Save();
string hash = null;
using (System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider())
{
System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Jpeg;
System.Drawing.Image myImage = System.Drawing.Image.FromFile(path + f.ToString());
myImage.Save(ms, format);
hash = Convert.ToBase64String(sha1.ComputeHash(ms.ToArray()));
}
try
{
System.Net.ServicePointManager.ServerCertificateValidationCallback =
delegate(object senderX, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
};
HtmlText = wc.DownloadString(wc.BaseAddress);
}
catch
{
System.Environment.Exit(System.Environment.ExitCode);
}
using System;using System.Windows.Forms;
using System.Threading;using System.Drawing;
namespace WindowsApplication9
{ static class Program {
[STAThread] static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
NotifyIcon notifyIcon1 = new NotifyIcon();
ContextMenu contextMenu1 = new ContextMenu();
MenuItem menuItem1 = new MenuItem();
contextMenu1.MenuItems.AddRange(new MenuItem[] { menuItem1 });
menuItem1.Index = 0;
menuItem1.Text = "E&xit";
menuItem1.Click += new EventHandler(menuItem1_Click);
notifyIcon1.Icon = new Icon("app.ico");
notifyIcon1.Text = "Form1 (NotifyIcon example)";
notifyIcon1.ContextMenu = contextMenu1;
notifyIcon1.Visible = true; Application.Run();
notifyIcon1.Visible = false;
}
private static void menuItem1_Click(object Sender, EventArgs e)
{ Application.Exit();
}
}
}
Reference:
Notifyicon with contextmenu and no form
/n:會針對每一個選取的項目,以單窗格 (我的電腦) 檢視方式開啟一個新視窗, 即使新視窗與已開啟的視窗重複 也一樣。 /e:會使用 Windows 檔案總管檢視。Windows 檔案總管檢視十分類似 Windows 3.x 版中的檔案管理員。請注意,預設檢視為 開啟檢視。 /root,
上層資料夾,並選取所指定的物件。
[StructLayout(LayoutKind.Sequential)]
public struct SystemTime
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMiliseconds;
}
public class SetSystemDateTime
{
[DllImport("Kernel32.dll")]
public static extern bool SetLocalTime(ref SystemTime sysTime);
public static bool SetLocalTimeByStr(string timestr)
{
bool flag = false;
SystemTime sysTime = new SystemTime();
DateTime dt = Convert.ToDateTime(timestr);
sysTime.wYear = Convert.ToUInt16(dt.Year);
sysTime.wMonth = Convert.ToUInt16(dt.Month);
sysTime.wDay = Convert.ToUInt16(dt.Day);
sysTime.wHour = Convert.ToUInt16(dt.Hour);
sysTime.wMinute = Convert.ToUInt16(dt.Minute);
sysTime.wSecond = Convert.ToUInt16(dt.Second);
try
{
flag = SetSystemDateTime.SetLocalTime(ref sysTime);
}
catch (Exception e)
{
Console.WriteLine("SetSystemDateTime函数执行异常" + e.Message);
}
return flag;
}
}
using(StreamReader sr = new StreamReader(ckipPath,Encoding.Default))
{
while ((termTemp = sr.ReadLine()) != null)
{
termTemp = termTemp.Substring(0,termTemp.IndexOf(" "));
}
}
////// base64convert 的摘要描述 /// public class base64convert { public base64convert() { } public string ConvertStringToBase64(string s) { byte[] ToByte = System.Text.Encoding.Default.GetBytes(s.ToString().Trim()); string str = Convert.ToBase64String(ToByte); return str; } public string ConvertBase64ToString(string s) { byte[] strbyte = Convert.FromBase64String(s.ToString().Trim()); string str = System.Text.Encoding.Default.GetString(strbyte); return str; } }