zoukankan      html  css  js  c++  java
  • C#(.net) 线程和最小化到托盘的例子

    自己写的一个使用线程和最小化到托盘的例子。 例子下载
    当你看这个例子你就知道线程的强大了,:-)

    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");
            }


        }

    }

    源码下载
  • 相关阅读:
    java 万能转换器 输入SQL 直接得到ArrayList
    社交原理
    意志力和自律
    windows phone 8.1 让项目开启蓝牙genericAttributeProfile
    C# JSON和对象之间互相转换
    QTC++监控USB插拔
    英语通假字
    #ifdef 支持Mac #ifndef 支持Windows #if defined (Q_OS_WIN) 应该可以再两个系统通用
    Qt5.3.2 在MAC yosemite下编译出错 Could not resolve SDK path
    Mac 用Ctr+C复制,Ctr+V 粘贴
  • 原文地址:https://www.cnblogs.com/wuyisky/p/923247.html
Copyright © 2011-2022 走看看