自己写的一个使用线程和最小化到托盘的例子。
例子下载
当你看这个例子你就知道线程的强大了,:-)
<script type="text/javascript"><!-- google_ad_client = "pub-4334685396432654"; //728x90, 创建于 07-12-2 google_ad_slot = "4549597583"; google_ad_width = 728; google_ad_height = 90; //--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
源码下载
当你看这个例子你就知道线程的强大了,:-)
<script type="text/javascript"><!-- google_ad_client = "pub-4334685396432654"; //728x90, 创建于 07-12-2 google_ad_slot = "4549597583"; google_ad_width = 728; google_ad_height = 90; //--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
using
System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
namespace thread
{
public partial class Form1 : Form
{
Thread t1;
public Form1()
{
InitializeComponent();
this.notifyIcon1.Visible = false;
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
}
private void button1_Click(object sender, EventArgs e)
{
t1 = new Thread(new ThreadStart(BackGroudProcess));
t1.Start();
}
private void BackGroudProcess()
{
int i = 1;
while (true)
{
listBox1.Items.Add("Iterations:" + i.ToString());
i++;
}
}
private void button2_Click(object sender, EventArgs e)
{
t1.Abort();
}
private void button3_Click(object sender, EventArgs e)
{
int i = 1;
while (true)
{
listBox1.Items.Add("Iterations:" + i.ToString());
i++;
}
}
private void Form1_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
this.Visible = false;
this.notifyIcon1.Visible = true;
}
}
private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;
WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://wuyisky.cnblogs.com");
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
namespace thread
{
public partial class Form1 : Form
{
Thread t1;
public Form1()
{
InitializeComponent();
this.notifyIcon1.Visible = false;
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
}
private void button1_Click(object sender, EventArgs e)
{
t1 = new Thread(new ThreadStart(BackGroudProcess));
t1.Start();
}
private void BackGroudProcess()
{
int i = 1;
while (true)
{
listBox1.Items.Add("Iterations:" + i.ToString());
i++;
}
}
private void button2_Click(object sender, EventArgs e)
{
t1.Abort();
}
private void button3_Click(object sender, EventArgs e)
{
int i = 1;
while (true)
{
listBox1.Items.Add("Iterations:" + i.ToString());
i++;
}
}
private void Form1_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
this.Visible = false;
this.notifyIcon1.Visible = true;
}
}
private void notifyIcon1_Click(object sender, EventArgs e)
{
this.Visible = true;
WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://wuyisky.cnblogs.com");
}
}
}
源码下载